Skip to content

SERVER_NAME still implicitly changes routing behavior #3465

@BoWuGit

Description

@BoWuGit

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions