![](/img/trans.png)
[英]res.redirect() outputs to browser “Found. Redirecting to <url>”
[英]res.redirect() not working in chrome - Found. Redirecting to
得到这个奇怪的
这是包含重定向的 express.js 中的后期调用。
app.post('/callback', (req, res)=> {
res.redirect('/deal')
});
这是我在 express.js 中的 get 调用
app.get('/deal', (req, res) => {
console.log("node.js /deal")
});
以上一个工作正常
更新:这里真的很麻烦。
表达:
app.post('/callback', (req, res)=> {
res.redirect('')
});
angular2-cli:
path: '',
redirectTo: '/deals'
component: PublicDealsComponent
为什么我说奇怪的是它在 Microsoft-edge 中完美运行,但在 chrome 中却没有。 是什么原因? 如何让它在 chrome 中工作?
发生这种情况是因为您无法将用户重定向到空string ('')
。 如果你想重定向到你的主路由,最后没有 ' /
' 那么你实际上可以使用请求中的req.protocol
和req.host
。 你可以参考下面的代码:
res.redirect(req.protocol + '://' + req.get('host'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.