2 months ago
I have a django app that accepts rest api requests and a react frontend on the same railway project. Using the public domain of django I can seemlessly call fetches and get the data I need. I am trying to use the internal network though for better speed and security but wasnt able to get it to work.
I simply added the priate domain of django to the django allowed hosts, and the react private domain to the allowed origins and csrf. Then I called the domain using fetch in react with http://.
But I then get timout errors. What am I missing here?
44 Replies
2 months ago
Private networking URLs are structured as .railway.internal.
2 months ago
(no markdown available for this content)
2 months ago
Yes.
2 months ago
^
2 months ago
You used https.
2 months ago
Also, you can’t use private networking for frontend code.
2 months ago
Clients (machines that access your website) do not have access to private networking.
So it is not directly called from the client, the client calls the internal proxy and the proxy calls the backend
2 months ago
Yes.
2 months ago
This depends on what port your application is listening to.
(no markdown available for this content)
Attachments
2 months ago
Either the application didn’t respond (wrong port?) or your proxy couldn’t resolve it.
2 months ago
I assume the frontend is able to reach the proxy successfully?
2 months ago
Try SSH-ing into your proxy service and curl -I your private networking URL and see if it can get a OK head response.
2 months ago
Right click on your service and Copy SSH Command to get the SSH command. You’ll need Railway CLI installed to use this.
getting this, tried installing with apt but
root@d4c0178c0e9c:/app# apt install curl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package curlokay tried node
root@d4c0178c0e9c:/app# node -e "require('http').get('http://backend.railway.internal:8080', (res) => console.log(res.statusCode))"
3012 months ago
Right. Sorry.
2 months ago
Are you able to see where it’s trying to redirect you to?
2 months ago
(I assume you redeployed your service after updating variables?)
(no markdown available for this content)
Attachments
The issue was SECURE_SSL_REDIRECT defaulting to True in the django settings