Im working with node.js and I would like to know how to display a 404.html instead of a \"404 Not Found\" message.
This is my server.js:
var http = r
H i ,
within your 404 case
response.writeHead(404, {"Content-Type": "text/plain"});
response.write("404 Not Found\n");
response.end();
You can change to
response.writeHead(404, {"Content-Type": "text/html"});
response.write(HTMLDATA);
response.end();
'HTMLDATA' being either a string of HTML or a reference to a file you have gathered.
response.writeHead() is always set before the response.write().
Also see we have set the response type to 'text/html'
http://nodejs.org/api/http.html#http_class_http_serverresponse