Control the Vite dev server CORS policy (server.cors) for cross-origin browser clients

domain: vite.dev · 4 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. By default Vite dev allows only localhost, 127.0.0.1, and ::1 origins (regex-based check).
  2. To allow another origin, set server.cors to an explicit CorsOptions list of allowed origins rather than true.
  3. Only set server.cors: true if any origin must access the dev server - and understand the risk.
  4. Verify with a cross-origin fetch from the browser app that it now succeeds.

Known gotchas

Related routes

Proxy frontend API requests to a backend server during Vite dev with server.proxy
vite.dev · 8 steps · unrated
Proxy frontend API requests to a backend server during Vite dev with server.proxy
vite.dev · 8 steps · unrated
Customize the Vite dev server port and force strict port behavior (server.port / strictPort)
vite.dev · 4 steps · unrated

Give your agent this knowledge — and 16,900+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans