[๐พ Error] Sever: `ERR_HTTP_HEADERS_SENT`
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
### ์๋ฌ๋ฅผ ์์ธํ ์์ฑํ์ธ์

### ์๋ฌ์ ์์ธ์ด ๋ฌด์์ธ๊ฐ์
1. ํด๋ผ์ด์ธํธ์๊ฒ ๋ ๊ฐ ์ด์์ response๋ฅผ ์ ๋ฌํ๊ธฐ ๋๋ฌธ์ ์๋ฌ๊ฐ ๋ฐ์ํ์ต๋๋ค.
2. ์ฝ๋์์ returnํด์ฃผ๋ res๊ฐ ํ๋๋ง ์๋ ๊ฒ์ ๋ณด๊ณ ์ด๋์ ์๋ฌ๊ฐ ๋ฌ๋์ง ํ์
ํ๊ธฐ ์ด๋ ค์ ์ต๋๋ค. ๋ ์์๋ณด๋ status์ sendStatus์ ์ฐจ์ด ๋๋ฌธ์ ์๋ฌ๊ฐ ๋ฐ์ํ์์ ์ ์ ์์์ต๋๋ค.
- status(): HTTP์ ์ํ๋ง ์ ํด์ฃผ๋ Method์
๋๋ค.
- sendStatus(): ์ํ๋ฅผ ์ ํด์ฃผ๊ณ 'ํด๋ผ์ด์ธํธ์๊ฒ ๋ณด๋ด๋' Method์
๋๋ค.
### ์๋ฌ๋ฅผ ์ด๋ป๊ฒ ํด๊ฒฐํ๋์
sendStatus์์ status๋ก ๋ฐ๊ฟ์ฃผ์์ต๋๋ค.
Before: `return res.sendStatus(200)).json({ message: "Success" });`
After: `return res.status(200).json({ message: "Success" });`
### ๊ฒ์ ํค์๋์ ๋์์ด ๋ ๋ ํผ๋ฐ์ค๋ฅผ ์์ฑํ์ธ์
[ERR_HTTP_HADERS_SENT](https://www.codementor.io/@oparaprosper79/understanding-node-error-err_http_headers_sent-117mpk82z8)
[status์ sendStatus์ ์ฐจ์ด](https://stackoverflow.com/questions/38620682/difference-between-response-status-vs-response-sendstatus-in-express/56275083)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.