Tagged: express

Express.js

CORS error: No 'Access-Control-Allow-Origin' header is present on the requested resource

Your backend isn't sending CORS headers that allow your frontend's origin. Install and configure the `cors` package with your frontend's exact URL(s), and make sure it's applied before your routes are registered.

Draft·
Express.js

Error: Cannot set headers after they are sent to the client

You're calling `res.send()`, `res.json()`, or similar more than once in the same request — usually because a code path doesn't `return` after sending a response, and execution continues into a second response call.

Draft·
Express.js

TypeError: app.use() requires a middleware function but got a undefined

You're passing `undefined` to `app.use()` — almost always because the thing you imported doesn't actually export what you think it does. Check for a missing `export default`, a mismatched named vs. default import, or a typo in the import path.

Draft·
Express.js

Error: listen EADDRINUSE: address already in use :::5000

Another process is already using the port your server is trying to listen on — often a previous `npm run dev` that didn't fully shut down. Kill the process using that port, or change your server's port in `.env`.

Draft·
Express.js

UnhandledPromiseRejectionWarning in an Express route handler

An async route handler threw an error that nothing caught — Express 4 doesn't automatically catch rejected promises in async route handlers, so the error escapes silently instead of reaching your error-handling middleware. Wrap async handlers in a try/catch (or a helper like `asyncHandler`) that forwards errors to `next()`.

Draft·