Skip to content

SERVER_NAME configuration should not implicitly change routing behavior. #998

@ekoka

Description

@ekoka

When Flask.config['SERVER_NAME'] is set to a domain (thedomain.com:8080) it alters the route matching behavior. Requests on "subdomained" urls (sub1.thedomain.com:8080/some/route) then only resolve to subdomained Blueprints (Blueprints with their 'subdomain' attribute set). With app.config['SERVER_NAME'] set to None, subdomained url would also properly resolve to non-subdomained Blueprints.

In other words, the presence of app.config['SERVER_NAME'] effectively serves as an implicit switch to subdomain matching behaviour for Blueprints.

(1) if this is intentional the documentation is not clear about it.
(2) the naming of that config is not very indicative of this behavior altering property either.
(3) this is not always the desirable behavior. Sometimes one still wants to use subdomains and set app.config['SERVER_NAME'], but does not want to map blueprints to subdomains. Such is the case for example, when using the value contained by app.config['SERVER_NAME'] to extract the subdomain info from the requested url in one's own user-defined function (a before_request handler for example). As it stands, the behavior altering property of app.config['SERVER_NAME'] forces developers in the latter use-case to set another more innocuous config property with the same value (e.g. app.config['SERVER_DOMAIN']).

I propose that a new config flag that will explicitly enable subdomain matching behavior be added. The presence of which would make app.config['SERVER_NAME'] mandatory (can't have subdomain support without it). But the presence of app.config['SERVER_NAME'] should not impose subdomain matching behavior.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions