[nodemon] restarting due to changes...
[nodemon] starting `node index.js`
backend server is running !
database connect
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are se
nt to the client
at new NodeError (node:internal/errors:371:5)
at ServerResponse.setHeader (node:_http_outgoing:576:11)
at ServerResponse.header (C:UsersDevToolDesktopProject-Reac
t-Finalreact2ecommerce-siteapinode_modulesexpresslibrespons
e.js:776:10)
at ServerResponse.send (C:UsersDevToolDesktopProject-React-
Finalreact2ecommerce-siteapinode_modulesexpresslibresponse.
js:170:12)
at ServerResponse.json (C:UsersDevToolDesktopProject-React-
Finalreact2ecommerce-siteapinode_modulesexpresslibresponse.
js:267:15)
at C:UsersDevToolDesktopProject-React-Finalreact2ecommer
ce-siteapiroutesauth.js:38:21
rnal/process/task_queues:96:5) {
code: 'ERR_HTTP_HEADERS_SENT'
}
[nodemon] app crashed - waiting for file changes before starting...
可能的问题是您在两个不同的地方发送响应,或者您在第一次发送res后更改了res OBJ中的某些内容。要解决此问题,请确保在发送响应之前使用关键字return
,这样可以防止代码完成执行。
一个小提示:总是提供代码可能会加快这个过程。