Connecting Service
shaykhouna
HOBBYOP

9 days ago

I keep having this error:

"Access to XMLHttpRequest at 'https://<service_url>.up.railway.app/api/auth/register' from origin 'https://<service_public_url>' 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.Understand this error useAuth.js:52"

I try to connect 2 services (front-end and back-end) it works if i go use RAILWAY_PUBLIC_DOMAIN (but you charge me for a permanent non-limit communication).

While you recommend me to use RAILWAY_PRIVATE_DOMAIN that on the other hand don't allow to communicate between service (see error above).

How to set up the communication between my services using RAILWAY_PRIVATE_DOMAIN ?

Solved$10 Bounty

2 Replies

Status changed to Open Railway 9 days ago


A end-user isn't on Railway's private network, so they must connect over the public domain.

You can fix the CORS error by including the Access-Control-Allow-Origin: https://<service_public_url> in the API's responses. (or Access-Control-Allow-Origin: * but that is not as secure.)


Either your have your CORS misconfigured, or you need to implement CORS middleware on your server. What is your tech stack so I can help you set it up?


Status changed to Solved shaykhouna 9 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...