Possible to share domain betwen wix frontend and railway backend?
Is it possible to host my backend API www.mydomain.com/api on railway, and a website www.mydomain.com on wix? Maybe using something like Caddyfile / reverse proxy?
20 Replies
definitely is possible, but may i ask, why?
though here's an example of what you want
https://mysite.up.railway.app/ (frontend, hosted on railway but doesn’t need to be)
https://mysite.up.railway.app/api/ (backend, also hosted on railway, but also doesn’t need to be)
how to do it
https://railway.app/template/7uDSyj
an example railway project
https://railway.app/project/35d8d571-4313-4049-9699-4e7db7f02a2f
It's for aesthetics when people call our api, and also they can visit our website if they see the API haha
This is possible even if the frontend is not on railway?
if it's easier, how can I configure a subdomain to railway instead? e.g. i have a website running at mydomain.com hosted on another server and i want railway to host api.mydomain.com
the actual frontend or backend can be anywhere but the main mydomain.com would need to be on railway since that is now the proxy domain
of course, you don't need a proxy for that at all though, host your backend and add api.mydomain.com to your railway service then setup the dns
hmm in the first case, if www.mydomain.com is hosted on railway, then how do I confiure the frontend on another server to use the same domain? Railways really only needs the subfolder mydomain.com/api
you would need to then use the proxy
Gotcha, I will look into that then. Thanks for always replying quickly 🙂
no problem 🙂
I did it using nginx and it’s working, but it’s very unstable
Is that expected in the first few hours?
no it's not expected at all
it would sometimes detect dns as currently pointing to the proxy server, and sometimes it would detect the previous site the dns was pointed to
yep I've seen that before with nginx, solution being, use caddy
I see
Will try that instead thanks!
please do use my template as a jumping off point
Will do!
Is Caddyfile only for static sites? I have a site that I use javascript for, is that possible to pass through proxy server?
I see many places use
api.mydomain.com
too and Railway is just a platform, it does not care front or back, it just runfr why not just shoving api to a subdomain?
The api is exposed to some end users and we r hoping this will help market our site
Is it possible to redirect api.domain.com to domain.com on wix, but keep everything with prefix api.domain.com/api in railway?
haven't working with wix for a long time but I think it must have some sort of redirects config
so you mean, the only way users can see is only your api, and you have nothing other than that?
I see some companies do this way: They put everything under something like
https://api.ourdomain/users
, https://api.ourdomain.com/projects/uuid/something
, but not the root, and in the root, they return only a string, "Go to https://ourdomain.com for more information"
, some startups even put job advertising over there, acts like an Easter egg.I think we will go with that, thanks guys for the help