Cannot reach my API with private network address

I want to send an http request to my api on railway from my frontend application which is also deployed on railway. however, I am getting following error: POST https://rental_management_api/v1/auth/login/server/admin net::ERR_NAME_NOT_RESOLVED my backend uses port number 443 and it's internal address is rental_management_api
No description
17 Replies
Percy
Percy11mo ago
Project ID: 010de26b-7fea-49a2-8845-1072c6586444
Hakan Kılıç
Hakan KılıçOP11mo ago
010de26b-7fea-49a2-8845-1072c6586444
Brody
Brody11mo ago
what kind of frontend app is this
Hakan Kılıç
Hakan KılıçOP11mo ago
next-js application
Brody
Brody11mo ago
and you are making these requests from the sever side of the frontend, correct?
Hakan Kılıç
Hakan KılıçOP11mo ago
yes my api responds when I make a request to it's external address
Brody
Brody11mo ago
have a look at this guide page, it should tell you everything you need to know - https://docs.railway.app/guides/private-networking but of course if you need any clarification feel free to ask!
Hakan Kılıç
Hakan KılıçOP11mo ago
I guess the reason why my code doesn't work is that I don't listen for ipv6 addresses in my api code
Brody
Brody11mo ago
that could be one reason, but i can tell you right now the url you are trying to fetch is wrong that guide page talks about what the proper internal url would look like
Hakan Kılıç
Hakan KılıçOP11mo ago
ok I see. Thank you sm. I will fix that and see if it works I corrected my address as follows: http://rental_management_api.railway.internal:443/v1/auth/login/server/admin I am getting following error this time: Mixed Content: The page at 'https://rentalmanagementadminpanel-production.up.railway.app/' was loaded over HTTPS, but requested an insecure resource 'http://rental_management_api.railway.internal:443/v1/auth/login/server/admin'. This request has been blocked; the content must be served over HTTPS.
Brody
Brody11mo ago
thats an error you would get from a browser you can't make a request to the private network from the users browser, wouldnt be much of a private network if so
Hakan Kılıç
Hakan KılıçOP11mo ago
yeah I see. Then how should I procede. I just want to deploy my front-end and my api on railway and establish communication between them. I am trying to the end-points of my api on railway from my front-end application should I just use my api's external address?
Brody
Brody11mo ago
yes you would have to use the external address so little correction with the information you have given me thus far, you meant to say no
Hakan Kılıç
Hakan KılıçOP11mo ago
sorry for the confusion. I miss understood and thank you for the answer
Brody
Brody11mo ago
no worries, happy to help
Hakan Kılıç
Hakan KılıçOP11mo ago
I am getting following error this time: Access to fetch at 'https://rentalmanagementapi-production.up.railway.app/v1/auth/login/server/admin' from origin 'https://rentalmanagementadminpanel-production.up.railway.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Brody
Brody11mo ago
you would need to setup cors in your backend
Want results from more Discord servers?
Add your server