10 months ago
We're facing CORS problems and 502 errors with our Railway-hosted app, despite open CORS configuration.
Setup
Node.js/Express backend on Railway
Needs CORS access for all origins
Issue
Server sets CORS headers (
app.use(cors())
)Clients get CORS errors + 502 Bad Gateway
Works locally with ngrok, fails on Railway
![CORS and 502 Errors]
See image.
Key Points
CORS headers set but not received by clients
Need open CORS for multiple client websites
502 errors suggest infrastructure problems
Questions
Why are CORS headers possibly being stripped?
Cause of 502 Bad Gateway errors?
Railway-specific config needed for open CORS?
How to ensure API accessibility from any origin?
We've verified server config, tested various CORS setups, and checked logs. Issue persists across browsers/devices.
Any insights on why headers might be stripped or requests failing with 502 would be greatly appreciated. Happy to provide more info if needed.
Thanks for your help!
0 Replies
10 months ago
what happens when you simply open the public domain in a browser
10 months ago
public domain of your api
10 months ago
and what happens if you open the problematic link that is returning cors issues?
One moment, I’m not on my laptop right now, but I do have that response somewhere
It doesn’t seem to give the response I had earlier, I’ll have a look later @Brody
@Brody upstream connect error or disconnect/reset before headers. reset reason: protocol error
But I do have to say that's for the GET request in the browser, I'll have a look what POST request in Postman tells me
10 months ago
yep this would be an issue with your application returning an error that just doesn't have cors headers set on the error, I would recommend adding verbose logging so you can narrow down the issue
This issue has been fixed, for the people seeing this because they have the same error. It's most likely the way and the order you handle your routes.
10 months ago
glad you where able to solve it, thanks for the update!