TypeError: res.writeHead is not a function
See original GitHub issueHi, I’ve done this with your latest code:
npm run build npm run start
Right after the Open http://localhost:8080 in a browser to view the app. message, I get an exception:
[0] /Users/me/projects/react-redux-universal-hot-example/src/server.js:105
[0] res.writeHead(500, { 'content-type': 'application/json' });
[0] ^
[0]
[0] TypeError: res.writeHead is not a function
[0] at ProxyServer.<anonymous> (/Users/me/projects/react-redux-universal-hot-example/src/server.js:55:9)
This is the code that fails:
// added the error handling to avoid https://github.com/nodejitsu/node-http-proxy/issues/527
proxy.on('error', (error, req, res) => {
let json;
if (error.code !== 'ECONNRESET') {
console.error('proxy error', error);
}
if (!res.headersSent) {
res.writeHead(500, {'content-type': 'application/json'}); // <- EXCEPTION
}
I installed the latest http-proxy package but nothing changed.
Thanks, Alvaro
Issue Analytics
- State:
- Created 8 years ago
- Comments:16
Top Results From Across the Web
TypeError: res.writeHead is not a function chapter 6 Fullstack ...
I have used the request and response in the http.createServer() in the wrong order, I used response then request, should be request and...
Read more >Error: response.write is not a function (Example) - Treehouse
Hey all, I am doing the exercise Build a Simple Dynamic Site with Node.js >> Reading from Files (7:30). When I try to...
Read more >Randomly getting TypeError: res.writeHead is not a function at ...
Hi, out of nowhere I'm getting this weird error on localhost running netlify dev… it's happening randomly, works for some time, ...
Read more >Fix errorMiddleware to prevent "TypeError: res.writeHead is ...
Fix errorMiddleware to prevent "TypeError: res.writeHead is not a function" (#3913. An error occurred. ) ... const errorMiddleware = (err, req, res) =>...
Read more >Node.js response.writeHead() Method - GeeksforGeeks
The response.writeHead() (Added in v1..0) property is an inbuilt property of the 'http' module which sends a response header to the request.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@stalkingbutler I also run into this problem whenever I change the server side code. Instead of removing the line all together, I added a check to see if
res.writeHead
is a function. So far so good.I know WHY!!! You must have run some other NodeJS App which use app cache on port 3000, and your browser must be Chrome! It’s ok when use Safari!!! @alvaro1728