R
Railway11mo ago
Dem

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
Brody
Brody11mo ago
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
Dem
DemOP11mo ago
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
Brody
Brody11mo ago
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
Dem
DemOP11mo ago
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
Brody
Brody11mo ago
you would need to then use the proxy
Dem
DemOP11mo ago
Gotcha, I will look into that then. Thanks for always replying quickly 🙂
Brody
Brody11mo ago
no problem 🙂
Dem
DemOP11mo ago
I did it using nginx and it’s working, but it’s very unstable Is that expected in the first few hours?
Brody
Brody11mo ago
no it's not expected at all
Dem
DemOP11mo ago
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
Brody
Brody11mo ago
yep I've seen that before with nginx, solution being, use caddy
Dem
DemOP11mo ago
I see Will try that instead thanks!
Brody
Brody11mo ago
please do use my template as a jumping off point
Dem
DemOP11mo ago
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?
Sang Dang
Sang Dang11mo ago
I see many places use api.mydomain.com too and Railway is just a platform, it does not care front or back, it just run
maddsua
maddsua11mo ago
fr why not just shoving api to a subdomain?
Dem
DemOP11mo ago
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?
maddsua
maddsua11mo ago
haven't working with wix for a long time but I think it must have some sort of redirects config
Sang Dang
Sang Dang11mo ago
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.
Dem
DemOP11mo ago
I think we will go with that, thanks guys for the help
Want results from more Discord servers?
Add your server