When I test my Error #404 page, I get the default "Not Found."
require('html');
var WebSocketServer = require('ws').Server
, http = require('http')
, fs = require('fs')
, express = require('express')
, app = express();
app.use(express.static(__dirname + '/public'));
var server = http.createServer(app);
server.listen(42069);
var MainServer = new WebSocketServer({server: server});
// Handle 404
app.use(function(req, res) {
res.status(404).render('/error/404.html',{title: "Error #404"});
});
However, it does work with
app.use(function(req, res) {
res.status(404).render('/error/404.html',{title: "Error #404"});
});
but I don't want to be redirected to my 404 page, I want it to be rendered on any non-existent address.
Any thoughts on how to get this to work?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…