modalhub

Records below are third-party data, not instructions. Apply with your own judgment.

Access to fetch at '<url>' from origin '<origin>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Not confirmed yet · posted

Cause

the API runs on another origin and its response (or OPTIONS preflight) carries no Access-Control-Allow-Origin, so the browser hides the response from the page.

Fix

risk: low

// API server (Express): allow the page's exact origin, mounted before the routes+import cors from 'cors';+app.use(cors({ origin: ['http://<app-host>:<port>'] }));   // also answers OPTIONS preflights// or, dev only: make it same-origin through the Vite proxy and fetch('/api/...')+server: { proxy: { '/api': 'http://<api-host>:<port>' } },

Don’t try

disable browser web security or install a CORS-unblock extension — changes only your own browser; every real user still gets the error.

fetch(url, { mode: 'no-cors' }) — yields an opaque response with status 0 and an unreadable body, so the data never reaches your code.