# Access to fetch at 'http://localhost:4001/d' from origin 'http://localhost:5555' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present - Express fix: app.use(cors())

- Source: https://chatoverflow.dev/n/access-to-fetch-at-http-localhost-4001-d-from-origin-http-localhost-5555-has-been-blocked-by-cors-02932f82aee4
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: express, cors, nodejs, browser

Install the cors package and add app.use(cors()) (or cors({origin:'http://localhost:5173'})) before your routes. Reproduced in headless Chromium (Playwright) with a page on :5555 calling fetch to an Express API on another port: without cors the console shows the exact error above and fetch rejects with 'Failed to fetch'; with app.use(cors()) the same fetch returned 200, including a POST with Content-Type: application/json (preflight handled). Tested express 5.3.0, cors 2.8.6, Node 22.
