2 months ago
Hi Railway team,
Approximately 1 week ago a regression was introduced where the first
request to a sleeping serverless container always fails with a CORS error.
This was NOT happening before, the same code and config was working fine.
What's happening:
When a serverless container is sleeping, a browser sends an HTTP OPTIONS
preflight before the real request. Railway's queuing proxy answers that
OPTIONS request immediately (before the container is up) with a response
that has no Access-Control-Allow-Origin header. The browser then blocks
all subsequent requests with:
"Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the
requested resource."
On a page refresh (container now warm), it works perfectly every time.
The second request in the same page load also always works.
My setup:
- FastAPI (Python) backends
- React/Vite frontend hosted on Vercel (https://app.studybuddyai.ca)
- Serverless enabled on Railway
- CORS middleware is correctly configured with allow_origins set to the
frontend domain
- Healthcheck path /health is configured in railway.json
- healthcheckTimeout: 60
What I've already confirmed:
- CORS middleware is set up correctly (works on warm containers)
- Healthcheck is configured, this doesn't help because the healthcheck
only runs on deploy, not on wake-from-sleep
- Issue happens across all serverless applications
- This was NOT happening ~1 week ago with the same code and configuration
Request:
Please either:
1. Have Railway's cold-start proxy pass through CORS request headers and
mirror them in the response (e.g. reflect Origin as
Access-Control-Allow-Origin on queued responses), OR
2. Advise what changed on Railway's infrastructure ~1 week ago that caused
this regression
This is causing a broken experience for all users who haven't visited
the page recently. Urgently need this resolved.
10 Replies
Status changed to Awaiting Railway Response Railway • 2 months ago
2 months ago
We believe we have already fixed this, but you would need to redeploy your service for that fix to take effect.
Status changed to Awaiting User Response Railway • 2 months ago
brody
We believe we have already fixed this, but you would need to redeploy your service for that fix to take effect.
2 months ago
I redeployed all the serverless services but the issue remains the same :/
Status changed to Awaiting Railway Response Railway • 2 months ago
2 months ago
Not sure how you have tested that; your service has not yet gone back to sleep.
Status changed to Awaiting User Response Railway • 2 months ago
brody
Not sure how you have tested that; your service has not yet gone back to sleep.
2 months ago
I did before I made this complaint
Status changed to Awaiting Railway Response Railway • 2 months ago
2 months ago
Yes, but at the time of this post's creation, you had an old deployment from before we released the fix.
So please let us know how this works going forward.
Status changed to Awaiting User Response Railway • 2 months ago
brody
Yes, but at the time of this post's creation, you had an old deployment from before we released the fix. So please let us know how this works going forward.
2 months ago
I just redeployed and tried accessing one of the paths on a sleeping server and got the same error.
ERROR:
Access to fetch at 'https://quiz-production-5bd1.up.railway.app/quiz-decks' from origin 'https://app.studybuddyai.ca' 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
quiz-production-5bd1.up.railway.app/quiz-decks:1 Failed to load resource: net::ERR_FAILEDUnderstand this error
index-CHOzXpfo.js:162 Error loading quiz data: TypeError: Failed to fetch (quiz-production-5bd1.up.railway.app)
at index-CHOzXpfo.js:162:7062
at L$e (index-CHOzXpfo.js:300:20879)
at async Promise.all (index 0)
at async se (index-CHOzXpfo.js:4141:125140)
(anonymous) @ index-CHOzXpfo.js:162Understand this error
quizzes:1 Access to fetch at 'https://quiz-production-5bd1.up.railway.app/quiz-stats' from origin 'https://app.studybuddyai.ca' 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
quiz-production-5bd1.up.railway.app/quiz-stats:1 Failed to load resource: net::ERR_FAILEDUnderstand this error
Status changed to Awaiting Railway Response Railway • 2 months ago
Status changed to Awaiting User Response Railway • 2 months ago
brody
Thank you, we will continue to look into this.
2 months ago
Hi, can I please be notified when this issue is fixed?
Status changed to Awaiting Railway Response Railway • 2 months ago
2 months ago
Should be fixed now. I have yet to see any issues with my sleeping services recently.
Status changed to Awaiting User Response Railway • 2 months ago
brody
Should be fixed now. I have yet to see any issues with my sleeping services recently.
2 months ago
Its working just fine now, thank you!
Status changed to Awaiting Railway Response Railway • 2 months ago
Status changed to Solved brody • 2 months ago