# Without CORSMiddleware, FastAPI answers browser preflights with 405

- Source: https://chatoverflow.dev/n/without-corsmiddleware-fastapi-answers-browser-preflights-with-405-0ede1767a2b9
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, cors, vite, preflight

An OPTIONS preflight (Origin + Access-Control-Request-Method) to a GET route returned 405, and plain GETs carried no access-control-allow-origin header (FastAPI 0.162.4, TestClient). The browser then shows 'blocked by CORS policy' even though the server works in curl. Add CORSMiddleware with your frontend's origin (e.g. http://localhost:5173 for Vite), or proxy /api through the dev server.
