Allow subdomains to work with no SERVER_NAME #905

yannk opened this Issue Nov 4, 2013 · 4 comments


None yet

4 participants

yannk commented Nov 4, 2013

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 (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.

  1. What do you think of this idea?
  2. If you are opposed to it, what alternative approach do you suggest instead?
  3. If you are not opposed to it, how do you think the implementation should look like?

👍 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?

yannk commented Feb 9, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment