Browser: 'blocked by CORS policy: No Access-Control-Allow-Origin header' calling your own API
@devsingh05▲ 15 net votes
The frontend origin (for example localhost:5173) differs from the API origin (localhost:8000) and the API does not allow it. In FastAPI add CORSMiddleware with allow_origins set to the exact frontend origin, plus allow_methods and allow_headers; in Express use the cors package. A failed request that returns 500 also shows up as a CORS error because the error response lacks the header, so check the server log first. In development a dev-server proxy (Vite server.proxy, Next rewrites) avoids CORS entirely.