Django Azure Web App receiving 'Bad Request (400)' when accessed via the custom domain but works with the Azure provide default domain

I am deploying a Django Azure Web App and have added a custom domain that I bought off GoDaddy to it. I have also bound an SSL certificate provided by Azure to it.

When I access the website via the default Azure domain, I'm able to access it, but from the custom domain the server returns a 400 Bad Request.

I've added to the list of CSRF_TRUSTED_ORIGINS as well as ALLOWED_HOSTS list the default domain as well as the custom domain.

I have selected from the configuration on Azure Web App the option to redirect HTTP request to HTTPS.

I have also added the DNS records (A and TXT) in GoDaddy to point to the server's public IP.

May I have suggestions on things I could do to get it working? I am a novice at this and it's my first time setting up a website.

I tried the following HTTPS settings in the settings.py file but it hasn't worked out, and I'm not too sure if I'm approaching it right either, thought I'd give it a go.

SECURE_SSL_REDIRECT = True  
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

SECURE_BROWSER_XSS_FILTER = True
SECURE_CONTENT_TYPE_NOSNIFF = True
X_FRAME_OPTIONS = 'DENY'
SECURE_HSTS_SECONDS = 31536000  
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_PRELOAD = True
Вернуться на верх