[ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

Server/Problems 2019. 7. 2. 17:02
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
 
    at ServerResponse.setHeader (_http_outgoing.js:470:11)
 
    at ServerResponse.header (E:\workspace\unity\Project\svnProjectM\RD\Friend\Server\node_modules\express\lib\response.js:771:10)
 
    at ServerResponse.send (E:\workspace\unity\Project\svnProjectM\RD\Friend\Server\node_modules\express\lib\response.js:170:12)
 
    at ServerResponse.json (E:\workspace\unity\Project\svnProjectM\RD\Friend\Server\node_modules\express\lib\response.js:267:15)
 
    at Query.connection.query (E:\workspace\unity\Project\svnProjectM\RD\Friend\Server\app.js:63:21)
 
    at Query.<anonymous> (E:\workspace\unity\Project\svnProjectM\RD\Friend\Server\node_modules\mysql\lib\Connection.js:525:10)
 
    at Query._callback (E:\workspace\unity\Project\svnProjectM\RD\Friend\Server\node_modules\mysql\lib\Connection.js:491:16)
 
    at Query.Sequence.end (E:\workspace\unity\Project\svnProjectM\RD\Friend\Server\node_modules\mysql\lib\protocol\sequences\Sequence.js:83:24)
 
    at Query._handleFinalResultPacket (E:\workspace\unity\Project\svnProjectM\RD\Friend\Server\node_modules\mysql\lib\protocol\sequences\Query.js:139:8)
 
    at Query.OkPacket (E:\workspace\unity\Project\svnProjectM\RD\Friend\Server\node_modules\mysql\lib\protocol\sequences\Query.js:72:10)
cs



client로부터 전송받은 data를 database에 저장후에 response 할때 자꾸 저런 오류가 났다.


왜인고 찾아보니 res.redirect처리가 잘못되었을 때인데,


나의 경우에는 Server에서 res.json을 통해 전송했는데 하단에 또 보내는 것이 중복되어 있었다.

'Server > Problems' 카테고리의 다른 글

MySQL undefined 오류  (0) 2019.07.01
Client does not support authentication protocol requested by server;  (0) 2019.06.28
: