Adding a custom domain URL for the Node App hosted on Railway

contrivelabs
HOBBY

a year ago

I need to add a custom domain to point to the Node deployment URL given by Railway as part of my hosting. My domain provider asks for IP address to add a sub domain as "A Record" entry. Can you please help me with this?

Solved

7 Replies

a year ago

Unfortunately A records will not work

Railway IPs are dynamic so they change over time, which means your custom domain will break after a bit if you use A records, that's why you need to use CNAMEs for custom domains on Railway


contrivelabs
HOBBY

a year ago

Thanks. Can you please help me with the value of CNAME that I should enter in my domain registrar?
For instance, I want to add backend-app as sub domain of my domain and I want that to point at "https://chitapp-node-production.up.railway.app/". Should I add railway URL in the CNMAE data field?


a year ago

To add a custom domain in Railway you can visit your service's settings by clicking on your service and going to the settings tab. From there you'll have the option to add custom domains. Once you add your custom domain, Railway will provide you the CNAME target to add


Status changed to Solved Railway about 1 year ago


contrivelabs
HOBBY

a year ago

Thanks. Yes I did that (wak9k9yy.up.railway.app.) and I see the setup complete message in Railway as well as below.
But I still don't see the redirection happen when I open backend-app.contrivelabs.org in browser (as it should open https://chitapp-node-production.up.railway.app/). Can you please help?

backend-app.contrivelabs.org
Setup complete


a year ago

Upon visiting https://backend-app.contrivelabs.org/ I'm greeted with a message "Chit app", it seems the domain is working fine.. Railway doesn't redirect anything anywhere, if you want https://backend-app.contrivelabs.org/ to redirect somewhere then you'd need to code that into your app


contrivelabs
HOBBY

a year ago

Awesome! And that's what I wanted! Looks like it took a while to propagate. Thanks a lot for your help!


a year ago

Awesome, no problem :D