R
Railway3mo ago
Abdule

Domain not working

Hi. I've created a Django application and tied it to a domain. I've inserted the CNAME Record etc. Railway did not use my domain, despite it claiming to. I then tried to remove my domain, and for some reason, my previously working application no longer works. I get this issue every time I try to visit my website. I tried redeploying, but it did not help. I've tried searching Google for answers, but without luck. Any help is appreciated
No description
Solution:
I have one last idea, make sure your app isn't redirecting http to https your app is behind Railway's proxy which does https for you and then I think it communicates with your app in http so if your app redirects http to https then it'll result in a 301 loop...
Jump to solution
12 Replies
Percy
Percy3mo ago
Project ID: ef2ad333-4cf8-4885-97b8-7c857b9171d0
Abdule
Abdule3mo ago
ef2ad333-4cf8-4885-97b8-7c857b9171d0
Fragly
Fragly3mo ago
Are you using Cloudflare?
Abdule
Abdule3mo ago
No
Fragly
Fragly3mo ago
the requests are going through Railway, so your client to railway connection is working fine are you sure your app isn't returning a 301? going to / returns a 301 redirecting to /, resulting in an infinite loop, causing you to reach too many redirects
Abdule
Abdule3mo ago
No, I am not sure. Is there any way to check / fix it
Fragly
Fragly3mo ago
You can check by looking at your app's code, how is it handling requests to /?
Abdule
Abdule3mo ago
It returns a page the index page
path("", views.home, name="home"),
path("", views.home, name="home"),
I just changed it to:
path("/", views.home, name="home"),
path("/", views.home, name="home"),
However, it would be odd if this is what is causing the problem. I have not changed anything about the pages and it was previously working just fine This change did not make a difference
Solution
Fragly
Fragly3mo ago
I have one last idea, make sure your app isn't redirecting http to https your app is behind Railway's proxy which does https for you and then I think it communicates with your app in http so if your app redirects http to https then it'll result in a 301 loop
Fragly
Fragly3mo ago
if you're using gunicorn then make sure that SECURE_HSTS_PRELOAD is not set to true
Abdule
Abdule3mo ago
Thank you so much That seems to have been the issue Everything is working perfectly now
Fragly
Fragly3mo ago
Awesome!