React App unable to connect to Express API Over Private Networking

seankuehlHOBBY

5 months ago

Hello, I am a user of the Hobby plan on Railway. I have an Express API connected to a MongoDB database. I also have a React App that queries this API. They are both Github Repositories hosted on Railway and are working over HTTPS and the private network. When the React App tries to connect to the Express API it's giving me " Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://elmira-stories-backend.railway.internal:5000/ " on Firefox and "Failed to load resource: net::ERR_NAME_NOT_RESOLVED" on Chrome. I've set the Express API to allow all origins. I've already tried flushing my DNS records and turning off my ad blocker which hasn't worked. Please advise on how I might be able to solve this issue. Project ID: 8ceb6ad1-2475-488b-9e98-f37c58a07db4

3 Replies

5 months ago

A client side react app would need to call the backend's public domain.


seankuehlHOBBY

5 months ago

Hello and thank you for your response. I have tried calling the API's public domain, but when I try to call the public domain of the API I am blocked by the Single Origin Policy. I think I'll need to add a proxy/reverse proxy into the environment to solve the problem. Let me know if you think there is another, easier solution.


5 months ago

Adding in a proxy while perfectly do-able and would likely solve the issue, is still a massive overcomplication for a simple CORS issue.


React App unable to connect to Express API Over Private Networking - Railway Help Station