R
Railway•5mo ago
SHxKM

Am I doing something wrong with custom domains? (Namecheap)

So I configured mydomain.online on Railway, and then went to Namecheap and entered (see screenshot). It's been about 20 minutes and no dice yet. Also, I'd like to have www.mydomain.online to always go to the apex/root. Should I change stuff right in order to not have issues later down the road?
No description
32 Replies
Percy
Percy•5mo ago
Project ID: 87f6d50b-7bab-488e-b802-02f9edc442e3
SHxKM
SHxKM•5mo ago
87f6d50b-7bab-488e-b802-02f9edc442e3
Brody
Brody•5mo ago
lets see the domains in the service settings please
SHxKM
SHxKM•5mo ago
Sure, I can't access the backend at all rn
Brody
Brody•5mo ago
yeah i know 😦
SHxKM
SHxKM•5mo ago
OK, mydomain.online is resolving correctly. What's the correct way to have the www redirect to the apex? Do I need to do this on Railway, or on Namecheap?
Brody
Brody•5mo ago
you could do it in code depending on what kind of app you are running?
SHxKM
SHxKM•5mo ago
I really don't want to do that in code :/ had that going on with Heroku and it was a nightmare with Django. Just felt real dirty
Brody
Brody•5mo ago
fair, well namecheap cant do https redirects, so that not an option, how about this https://github.com/brody192/domain-redirect-template you would remove the www subdomain from your current service, deploy this repo as a new service and put the www subdomain on that service
SHxKM
SHxKM•5mo ago
So, I don't have the www subdomain in the current service at all.
Brody
Brody•5mo ago
correct
SHxKM
SHxKM•5mo ago
I'm willing to move to another domain provider to avoid deploying a service just for redirection. Any provider that does support that?
Brody
Brody•5mo ago
cloudflare can with page rules, you would need to have the www subdomain on the service for that (so that it will have a valid cert) you'd only need to use cloudflare's nameservers
SHxKM
SHxKM•5mo ago
Thanks for the help @Brody !
Brody
Brody•5mo ago
no problem!
SHxKM
SHxKM•5mo ago
Just saw a thread where it was possible to link both domains foo.com and www.foo.com in the same Railway service, and then play around with A records?
Brody
Brody•5mo ago
nope, I don't know what thread you read lol never do anything with a records until railway has static ips
SHxKM
SHxKM•5mo ago
Yeah nevermind, those were two apps.
Brody
Brody•5mo ago
I also don't see any mention of A records?
SHxKM
SHxKM•5mo ago
Well, you've been correct more than a few times these two days...
Brody
Brody•5mo ago
I've been doing this a while
SHxKM
SHxKM•5mo ago
Coming back to this @Brody, why can’t I add both the apex and the www to Railway, and just put two CNAME records at Namecheap?
Brody
Brody•5mo ago
you can, that wouldn’t redirect anything though, i was under the impression that you wanted www -> non www
SHxKM
SHxKM•5mo ago
You’re right :/
Brody
Brody•5mo ago
django right? is a middleware that reads the host and sends a redirect that difficult or clunky?
SHxKM
SHxKM•5mo ago
@Brody last time I tried it (6 years ago) I was a beginner programmer so I may have overstated how clunky it is. Or understated how clunky I was.
Brody
Brody•5mo ago
please do not use A records for anything railway related, railway will only ever provide you with a cname and last i checked, namecheap doesn’t do https redirecting
SHxKM
SHxKM•5mo ago
@Brody isn’t it considered best practice to redirect before the app layer? Or am I making stuff up here?
Brody
Brody•5mo ago
if you have the redirect middleware at the top, i cant see any issues for most low to medium load scenarios
SHxKM
SHxKM•5mo ago
This looks like it should do, but it says:
…You should also make sure your HTTPS certificate includes both domains.
I guess this is handled by Railway?
Brody
Brody•5mo ago
You should also make sure your HTTPS certificate includes both domains... I guess this is handled by Railway?
as long as you have both your www and your bare domain in the custom domains, yes, both will receive certs!