API Returns HTML to Frontend but JSON in Browser (Railway + Vercel)
shreyasayyengar
HOBBYOP

4 months ago

hey, i'm hoping someone can help because i'm stuck regarding API requests having different behaviour on dev vs prod

i have my API (using ORPC routes) deployed on Railway and my frontend (React + TanStack Query) deployed on Vercel. In development everything works fine: react requests the API and gets proper JSON responses.

but once deployed, the frontend’s requests to the production API come back as HTML/File blobs instead of JSON. The strange part: if I open the production API URL directly in the browser, I do see the correct JSON. It’s only the frontend fetches that receive HTML.

a friend suggested this might be a Railway quirk where requests from the website somehow get routed incorrectly, but we aren’t sure. also thought it might be CORS-related; i tried updating CORS to include localhost, my domain, and the Vercel-owned domain, but that didn’t fix it.

has anyone run into this issue or know what could cause the frontend fetch to return HTML while direct browser access returns JSON?

Solved

3 Replies

Any clue as to what the HTML/file blobs contain?


shreyasayyengar
HOBBYOP

4 months ago

nevermind, silly mistake on my part. issue was mixed content blocking. https site calling an http endpoint.


shreyasayyengar
HOBBYOP

4 months ago

!s


Status changed to Solved brody 4 months ago


Loading...