CORS Preflight (OPTIONS) Requests Not Reaching Express App – Unable to Support Cross-Origin API Calls
indeliblegroup
PROOP

7 months ago

Hello Railway Support,
I am experiencing a persistent CORS issue with my Node.js/Express backend deployed on Railway on my nurturing-playfulness. My setup is as follows:
Frontend: Deployed on Vercel at https://aura-ride-d9wl.vercel.app
Backend
: Deployed on Railway at https://auraride-production.up.railway.app
CORS
Configuration:
I am using the cors middleware in Express, with a global handler for all origins and credentials enabled.
I have also added a global handler for all OPTIONS requests (app.options('*', cors(...))).
My FRONTEND_URL environment variable is set to the correct Vercel URL (no trailing slash, no quotes).
The Problem:
When my frontend tries to make a POST request (e.g., to /api/auth/signup), the browser sends a CORS preflight (OPTIONS) request.
This OPTIONS request receives a 405 Method Not Allowed response, and no Access-Control-Allow-Origin header is present.
My Express app never receives the OPTIONS request, so it cannot respond with the necessary CORS headers.
I have confirmed this by running:
Apply to server.js
"
The response is always:
Apply to server.js
.
I have also checked Railway logs and see no evidence that the OPTIONS request is reaching my app.
What I’ve Tried:
Verified my CORS and OPTIONS middleware placement in Express.
Temporarily allowed all origins and credentials for debugging.
Confirmed the issue is not present when running locally or with other hosts.
Searched Railway documentation and community for similar issues.
Conclusion:
It appears that Railway’s HTTP edge proxy is not forwarding OPTIONS requests for non-GET/HEAD routes to my Express app, which breaks CORS for all cross-origin API calls.
Request:
Can you please enable forwarding of OPTIONS requests for my service (https://auraride-production.up.railway.app)?
Or
, advise on how to configure my Railway project so that all HTTP methods (including OPTIONS) are properly forwarded to my backend?
This is blocking my production deployment, as my Vercel frontend cannot communicate with my Railway backend due to CORS preflight failures.
Thank you for your help!

$20 Bounty

3 Replies

Railway
BOT

7 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


brody
EMPLOYEE

7 months ago

Hello,

The 405 status code is being returned by your application, not by our proxy. There is no circumstance where our proxy would return a 405. Additionally, all methods are always passed transparently to your application.

I'm going to open this up to our community so that they may help you debug this application issue.

Best,
Brody


Status changed to Awaiting User Response Railway 7 months ago


brody
EMPLOYEE

7 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 7 months ago


vivek
FREE

7 months ago

Can you share your current CORS configuration(code snippet)?

To better diagnose this issue, could you please share:

  1. Your current server.js or main app file showing how you've configured CORS

  2. The exact middleware order you're using

  3. Your current CORS options object

This will help identify if it's a configuration issue vs. a Railway-specific problem. The 405 error suggests the OPTIONS handler isn't being registered correctly, which is usually a middleware ordering issue rather than Railway blocking the requests.

You can sanitize any sensitive URLs/tokens before sharing. Thanks!


Loading...