我有一个问题,比如在执行gulp
或npm start
命令来启动我的Node应用程序时,需要大约2分钟才能完成。但是当他们点击url访问应用程序时,这2分钟的客户端要求他们应该获得自定义错误页面。如何为此senario配置自定义错误页面?
答案 0 :(得分:0)
如果要重定向到其他网址,则需要添加" http"在res.redirect中,请查看以下代码段:
app.get('*', function (req, res) {
request.get({
url: 'localhost:8089',
agentOptions: {
rejectUnauthorized: false
}
}, function (error, response, body) {
if (error) {
res.redirect('http://www.google.com/')
}
});
});
在您的情况下,它将是:
res.redirect('http://localhost:8011/#/ErrorPage.html')