How to Fix a CORS Error When Testing in Chrome
What a CORS error means, the real fix on the server or dev proxy, and safe ways to add CORS headers in your browser while testing, with their limits.
Disclosure: I build HeaderDesk, the extension this post features. The advice stands on its own; the tool is just how I put it into practice.

A CORS error means the server did not send the Access-Control-Allow-Origin header your page needs, so Chrome refuses to hand the response to your JavaScript. The real fix is on the server or in your dev server: send the right headers, or proxy the API through your own origin. While you wait for that fix, or when you are testing against an API you do not control, you can add the missing headers in your browser only, with DevTools overrides or a header extension. I build one, HeaderDesk, and this guide covers every option and where each one stops working.
Read the Error First
Open DevTools, Console tab. Chrome names the missing piece: "No 'Access-Control-Allow-Origin' header is present", "Response to preflight request doesn't pass access control check", or a mismatch between the origin and a wildcard with credentials. Which one you see decides the fix.
Fix 1: Send the Headers From the Server
If you own the API, this is the fix that ships. Answer with Access-Control-Allow-Origin set to the exact origin of your page (for example http://localhost:5173), and if the request uses credentials, add Access-Control-Allow-Credentials: true; a wildcard * is not allowed together with credentials. For requests with custom headers or methods like PUT and DELETE, the server must also answer the preflight OPTIONS request with a 2xx status and the Access-Control-Allow-Methods and Access-Control-Allow-Headers it accepts.
Fix 2: Proxy Through Your Dev Server
If the frontend and API live on different origins only during development, let your dev server forward API calls, so the browser only ever talks to one origin and CORS never applies. Vite has a server.proxy setting, and most other frameworks have an equivalent.
export default {
server: {
proxy: { '/api': 'http://localhost:8080' },
},
}Fix 3: Override the Response Headers in DevTools
For a quick test, Chrome DevTools can change response headers locally. In the Network panel, right-click the failing request, choose Override headers, pick a folder for overrides when asked, and add Access-Control-Allow-Origin. It only applies while DevTools is open, one request pattern at a time, and nothing is changed on the server.
Fix 4: A Header Extension, for Repeatable Testing
When you test against the same API every day, an extension keeps the rule without DevTools open. HeaderDesk has an "Allow CORS" preset that adds the Access-Control response headers your browser checks, scoped to the sites you choose, and you switch it off with one click when you are done.
Here is what I measured while building it, so you know when not to bother. An added Access-Control-Allow-Origin fixes a simple GET and a credentialed GET. A preflight is fixed only if the server already answers the OPTIONS request with a 2xx status; a 404 or 405 on the preflight still fails, because headers can't change a status code. The preset refuses a wildcard origin with credentials, since Chrome would reject it anyway. And it changes only what your browser sees: a server that rejects the request itself still rejects it.
The Fixes Compared
| Fix | Ships to users | Needs | Limits |
|---|---|---|---|
| Server headers | Yes | Access to the API | None: this is the real fix |
| Dev server proxy | No, development only | Your build tool config | Different setup in production |
| DevTools Override headers | No, your browser only | DevTools open | Per request pattern; gone when DevTools closes |
| HeaderDesk "Allow CORS" | No, your browser only | The extension, and the sites allowed | No fix for a failing preflight status or a server that refuses |
What Not to Do
Avoid launching Chrome with --disable-web-security for everyday work. It turns off the same-origin policy for every site in that profile, and it is easy to forget the window is unsafe. If you must, use a separate --user-data-dir and close it when you are done. The same goes for extensions that add Access-Control-Allow-Origin: * to every site: keep anything like that scoped and switched off when you are not testing.
Requests to localhost From a Public Site
Recent Chrome versions restrict public websites from calling servers on your own computer or local network, and may ask for permission first. If a hosted page cannot reach your local API even with the right CORS headers, that restriction is the likely cause, not CORS.
The Short Version
Read the console error, fix the headers on the server or proxy through your dev server, and use browser-side overrides only for testing: DevTools for a one-off, a scoped header extension when you test the same API every day.