Koa2: setting ctx.status prior to ctx.redirect call does not yield any effect.
See original GitHub issueIs this a bug?
per documentation https://github.com/koajs/koa/blob/v2.x/docs/api/response.md#responseredirecturl-alt
if i set ctx.status prior ctx.redirect call my response status should be set to what ever is i specify it to, but this does not happen in my case. I have middle wear that redirects visitor for any path that does not fall under exception if they do not have authenticated session.
if (authRequired && !ctx.isAuthenticated()) {
ctx.status = authConfig.authRequiredRedirect.statusCode;
ctx.redirect(authConfig.authRequiredRedirect.path);
}
Am I missing something?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Koa - next generation web framework for node.js
If an error is in the req/res cycle and it is not possible to respond to the client, the Context instance is also...
Read more >Koa's `ctx.status` not getting sent to client - Stack Overflow
Looking at the Koa code, it has specific handling for ENOENT (which is the error that gets thrown when a file doesn't exist):...
Read more >Sending Response with Koa - Medium
We can send response status codes by setting the status code value to the responbse.status property. ... ctx.status = 202; ctx.body = 'accepted';...
Read more >Koa-router: Router Middleware for Koa - Morioh
session middleware will run before authorize router .use(session()) ... router.all('/login', ctx => { ctx.redirect('/sign-in'); ctx.status = 301; });.
Read more >Efficacy of sCOMP and sCTX-I in Diagnosis of Knee ...
Only CTX-I was also able to distinguish between K–L grades I and II, ... Radiographs scored as grade 0 (normal) showed no radiographic ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yeah, i am doing it wrong. i will close both : ) thanks for help
Maybe i am doing this wrong. Possibly my understanding of this subject is off. let me consult web for a bit.
Original goal was to respond to none-auth user with 401 and redirect them to login page.