8 days ago
I am getting this error "Access to XMLHttpRequest at 'https://test-jedi-backend.railway.app/api/v1/auth/login' from origin 'https://test-jedi-software.vercel.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'https://railway.com' that is not equal to the supplied origin." everytime I try to make a request to my backend service. Request Method
OPTIONS
Status Code
204 No Content, access-control-allow-headers
content-type
access-control-allow-methods
GET,HEAD,PUT,POST,DELETE,PATCH
access-control-allow-origin
It appears the issue is coming from railway but I'm not sure why. In what ways can I resolve this issue?
1 Replies
Status changed to Open Railway • 8 days ago
8 days ago
You need to change the allowed origins in your CORS middleware. The origin should be set to https://test-jedi-software.vercel.app .
If you are using express for example, it would be something like this:
const corsOptions = {
origin: "https://test-jedi-software.vercel.app",
methods: "GET,HEAD,PUT,POST,DELETE,PATCH",
};