-
카테고리
-
세부 분야
풀스택
-
해결 여부
미해결
Content-Type 질문드립니다.
22.11.15 17:05 작성 조회수 83
0
const http = require("http");
const fs = require("fs").promises;
const server = http
.createServer(async (req, res) => {
try {
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
const data = await fs.readFile("./index.html");
res.end(data);
} catch (e) {
console.error(e);
res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
res.end(e.message);
}
})
.listen(8080);
server.on("listening", () => console.log("8080번 port에서 실행중..."));
응답에 Content-Type을 넣어서 Network를 확인했는데 아래와 같이 나옵니다.
왜 text/html; charset=utf-8
이 아니라 text/javascript
로 나오는 건가요?
답변을 작성해보세요.
답변 1