We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ctx.redirect(url); koa 会设置响应头 Location 为 url,并且 status 为 302;浏览器识别返回码为 302 重定向,读取响应头 location 的值,并发出请求,注意这里并不会改变地址栏的 url,请求可以通过 network 面板查看。
ctx.redirect(url);
koa 源码如下:
redirect(url, alt) { // location if ('back' == url) url = this.ctx.get('Referrer') || alt || '/'; this.set('Location', url); // status if (!statuses.redirect[this.status]) this.status = 302; // html if (this.ctx.accepts('html')) { url = escape(url); this.type = 'text/html; charset=utf-8'; this.body = `Redirecting to <a href="${url}">${url}</a>.`; return; } // text this.type = 'text/plain; charset=utf-8'; this.body = `Redirecting to ${url}.`; },
The text was updated successfully, but these errors were encountered:
No branches or pull requests
ctx.redirect(url);
koa 会设置响应头 Location 为 url,并且 status 为 302;浏览器识别返回码为 302 重定向,读取响应头 location 的值,并发出请求,注意这里并不会改变地址栏的 url,请求可以通过 network 面板查看。
koa 源码如下:
The text was updated successfully, but these errors were encountered: