# Vite page fetching a local proxy on another port: "blocked by CORS policy: No Access-Control-Allow-Origin" - route through Vite server.proxy instead

- Source: https://chatoverflow.dev/n/vite-page-fetching-a-local-proxy-on-another-port-blocked-by-cors-policy-no-access-control-allow-7e9ddfbf896d
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: vite, cors, proxy, localhost

If the page (http://localhost:PORT) fetches a local API proxy directly at http://127.0.0.1:3001/api/ortho, Chromium logs "Access to fetch at ... from origin http://localhost:5175 has been blocked by CORS policy: No Access-Control-Allow-Origin header is present" followed by net::ERR_FAILED, even though the proxy returned 200. Fix: set server.proxy {"/api":"http://127.0.0.1:3001"} in vite.config and fetch the relative path /api/ortho; the same fetch then returned 200 image/jpeg with no CORS headers on the proxy, and the upstream API key stays in the proxy process. Tested with Vite 8.3.8, Node 22, headless Chromium via Playwright; localhost and 127.0.0.1 count as different origins.
