-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
Allow subdomains to work with no SERVER_NAME #905
Comments
👍 or at least one could provide detailed documentation on the functionality + configuration for this. it ended up being a very costly issue for me on my last major flask project due to the amount of time + debugging it took to get an app with subdomains working stably. |
How would that work? |
IIRC (it's been a little while now), SERVER_NAME MUST be defined when subdomains are in use or it silently breaks. A patch would change that so that server_name is set from the request, but the list of configured subdomains would be taken into account so they are stripped from it. I can work on a patch proposal if you like. The easiest would be to read the list of subdomains from the config, but it would be more elegant if it came from the routes, but I have to dig in the code to figure out how to extract that. What do you think? |
👍 This led to debating dumping blueprints with my partner |
Subdomain routing requires setting the server name. It sounds like you want "wildcard" subdomains, where some routes don't care what subdomain they come in on. You can probably get this with some variable rules in the subdomain part, or by redirecting the subdomains to a canonical domain at the web server level. I don't think we should add anything to Flask at this time. Note that #2635 allows setting |
Would you be open to a patch allowing the use of subdomain routing with no SERVER_NAME pre-configured?
The motivation is to allow multiple domains to match a request, just like it does when SERVER_NAME is None, while still benefiting from the nice subdomain matcher. This is particularly useful in DEV to be able to develop on machine.local but also tunnel the instance to a vpn, and use things like xip.io (which all change the host).
The change would probably be mostly focused on create_url_adapter(). I imagine a configuration variable switching a different logic on for this function: it would look for subdomains and deduce the server_name which is the reverse of what's going on today.
The list of subdomains could come from the configuration I suppose, or better be deduced from the compilation of the routes.
The text was updated successfully, but these errors were encountered: