我没有使用任何模板引擎。我想将所有内容重定向到我的静态文件 /public/desktop.html
app.use(express.static(__dirname + '/public'));
function route(req, res, next) {
res.sendfile(__dirname + '/public/desktop.html');
myURL = url.parse(req.url).pathname;
}
如果我使用它并访问 url 上的 'localhost:8080/anypath 效果很好
但是如果我尝试 'localhost:8080/' 我什么也得不到:
app.get('*', route);
如果我使用其中任何一个,我将无法访问任何内容:
app.get('/', route);
app.get('/*', route);