“。重定向到”快递

". Redirecting to" express

致敬, 我目前很难找到 res.redirect('/index') 渲染的原因:

<p>OK. Redirecting to <a href="/index">/</a></p>

而不是在页面上直接重定向。

我在文件 ./node_modules/express/lib/response.js (ctrl + F ". Redirecting to") 中查找并找到了创建此 HTML 代码的行,但我不明白为什么打印而不是我正在等待的重定向。 this page

上的文档中对此一无所获

如何获得正常的重定向?

基地来自eSpress-generator

它不呈现该内容 而不是 重定向,它呈现该内容 除了 重定向。

Here Express sets the appropriate Location header and then here 它设置(默认)302 HTTP 状态代码。

对于路上的任何人。

如果您的 res.redirect(202, '/to'); 中有状态代码,请将其删除。

这对我有用。应该看起来像这样。 res.redirect('/to')