Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SERVER_NAME still implicitly changes routing behavior #3465

Closed
BoWuGit opened this issue Jan 12, 2020 · 3 comments
Closed

SERVER_NAME still implicitly changes routing behavior #3465

BoWuGit opened this issue Jan 12, 2020 · 3 comments

Comments

@BoWuGit
Copy link

BoWuGit commented Jan 12, 2020

Just like this old issue said, routing behavior changed even when subdomain_matching defaults to false, so take this repository as example, if you comment following lines,

@app.before_request
def start():
    """
    init globals and set the schema search path for the current request.
    """
    g.user = session.get('user', None)
    current_url = urlparse(request.url)
    subdomain = current_url.hostname.split('.')

    if subdomain.__len__() > 2:
        """
        redirect to home page
        """
        if current_url.path == "/":
            return redirect(url_for('index'))
        pass
    pass

then requests to user1.flask-subdomain.com won't route to index, default 404 as response. Or am I missing something, as a result have misunderstood it. Thanks very much.

@app.route('/')
def index():
    return render_template('index.html')

Environment

  • Python version: 3.6
  • Flask version: 1.1.1
  • Werkzeug version: 0.16.0
@ghost

This comment has been minimized.

@davidism
Copy link
Member

I'm sorry, it looks like you're asking about code in another repository. As far as I can tell SERVER_NAME works as intended at this point.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
@davidism
Copy link
Member

#5634 in Flask 3.1 will further address this. SERVER_NAME no longer affects routing except to determine subdomains if subdomain_matching is enabled.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants