
error: Cannot set headers after they are sent to the client
- 하나의 라우터에서 응답(res)을 2번이상 보낼 경우 발생(미들웨어 포함)

- 응답(send sendFile json 등) 2번 이상 보낼 경우 error
const express = require("express");
const path = require("path");
const app = express();
app.set("port", process.env.PORT || 3000);
app.get("/", (req, res) => {
res.send("Node Server");
res.sendFile(path.join(__dirname, "index.html"));
})
app.use((err, req, res, next) => {
console.log("치명적인 에러 발생");
})
app.listen(app.get("port"), () => {
console.log(3000);
})
'기타 > 에러' 카테고리의 다른 글
Error: error:1E08010C:DECODER routines::unsupported (1) | 2023.01.06 |
---|---|
TypeError: Class constructor Model cannot be invoked without 'new' (0) | 2022.06.06 |
augmentations for the global scope can only be directly nested in external modules ts(2669) (0) | 2022.06.02 |
ReferenceError: __dirname is not defined (0) | 2022.04.09 |