CORS
-
ExpressJS
Fix “Blocked by CORS Policy” in a MERN App (React + Express)
The browser blocks your React app from reading the API response because Express did not send the right CORS headers. Install the cors package and add app.use(cors({ origin: "http://localhost:5173" })) before your routes. If you send cookies, also set credentials: true on the server and credentials: "include" (or withCredentials in Axios) on the client, and never use origin "*" with credentials.

