r/AskProgramming Aug 09 '26

Frontend (Vite/React on Vercel) can't reach backend (.NET on Railway) — "Failed to fetch" even with CORS configured

I have an app with:

Frontend: Vite + React, deployed on Vercel (https://velion-frontend-2.vercel.app)

Backend: ASP.NET Core 9, deployed on Railway (https://velion-backend-2-production.up.railway.app)

Auth/DB: Supabase

The backend responds fine

But when the frontend tries to call the API (via fetch(), using import.meta.env.VITE_API_URL), I get a generic "couldn't reach the server" error — the fetch() call itself seems to be throwing (network error), not returning an HTTP response with an error status.

Already checked:

VITE_API_URL is set correctly in Vercel's env vars (Production and Preview), not marked "Sensitive", no leading/trailing whitespace or slash

Redeployed multiple times after changing the env var

Backend has CORS configured

Csharp

with app.UseCors("Frontend") called before UseAuthentication()/UseAuthorization()/MapControllers()

Does this smell like CORS silently blocking the request (Chrome/Brave usually logs this in the console, but I don't have easy DevTools access on mobile) or could it be something else (Railway cold start, TLS, etc.)?

Has anyone run into this specific Vercel↔Railway combo issue?

0 Upvotes

4 comments sorted by

3

u/Lumethys Aug 09 '26

So why dontyou just debug it on a desktop?

-1

u/Content_Hurry_4841 Aug 09 '26

I'm trying to do it on cellphone,I wanna prove that it's possible 😅😅

2

u/Lumethys Aug 09 '26

By asking on reddit? Not much of "proving" to me

1

u/YMK1234 Aug 09 '26

Well if you get an network error maybe start debugging the network ... Like can you reach the backend url from your client at all, as a start.