My two subdomains aren't routing correctly.
Here is my middleware class
MIDDLEWARE_CLASSES = [
'subdomains.middleware.SubdomainURLRoutingMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
As you can see SubdomainURL Routing middleware is above Common.
The configuration is like so:
ROOT_URLCONF = 'deltaforce.urls'
SUBDOMAIN_URLCONFS = {
'api': 'errorPage.urls',
None: 'interface.urls',
}
The issue is both abc.com and api.abc.com are routing to the None/interface.urls
.
I came to know about the same from the 404 page on each. The difference between deltaforce.urls
and interface.urls
is the default admin console which is not showing up which is a good sign that it is not using ROOT_URLCONF
but the api
is also showing similar behavior as the only page in error page is 404 which i am using to test it out. It's 404 page is showing a list of urls from interface.
Here is something else that might be important:
ALLOWED_HOSTS = [".abc.com"]
abc.com
and other subdomains are there is a /etc/hosts
file and finally this is all behind an nginx proxy which passes host headers properly based on requested url on 404 page.