a year ago
Project ID: 358600cb-32ed-4c25-a1a0-5e28c7a14ed9
I have NextJS frontend that need to connect to a Django backend service. I wonder if it is possible to connect via RAILWAYPRIVATEDOMAIN somehow or am i confusing myself somewhere ?
19 Replies
All API call are in server action so it run on server, so it should have access to RAILWAYPRIVATEDOMAIN right ?
a year ago
Remember, your frontend's code will be running on a different computer in a different network so it won't be able to connect via the private network to the backend
a year ago
it's meant for backend services to communicate among each other
a year ago
using the private network for backend services to communicate has a lot of benefits, for example:
Not exposed publicly, meaning better security
Faster communication
No egress costs
that's what I also understand so it should work in my case right ? since NextJS server action is call in the server (backend) so it should be able to communicate with django (backend) right ?
but when I try to use RAILWAYPRIVATEDOMAIN in http or https format, it doesn't work. It only work when I use RAILWAYPUBLICDOMAIN ?
a year ago
ohh, if you're running it as a server action then yea sorry for my confusion
a year ago
make sure you're also specifying the port when you're connecting to the private domain (unless it's running on port 80)
a year ago
a service (foo) running on port 3000's private connection would look like this:
[http://foo.railway.internal:3000](http://foo.railway.internal:3000)
so RAILWAYPRIVATEDOMAIN does not forward port like RAILWAYPUBLICDOMAIN right ?
a year ago
yea, pretty much
HTTP uses port 80 by default and HTTPS uses port 443 by default
on the public domain Railway's proxy automatically bridges port 443 to your service's port
but on the private domain there is no proxy like that so you have to specify the port if it's not running on the default port
a year ago
awesome, glad I could help 🙂
alright it work now. but to add a bit more RAILWAYPRIVATEDOMAIN use ipv6 so for it to work the django backend just need to also listen to ipv6.
a year ago
oh true, glad you got it working!
a year ago
!s
Status changed to Solved dev • about 1 year ago