Response headers will be ignored/removed while using ctx.throw.
See original GitHub issuectx.set( 'Access-Control-Allow-Origin', '*' );
ctx.throw( 404 );
By using the code above, the header of Access-Control-Allow-Origin
will not be sent with responding. Even though I can use res.statusCode
instead, but I think the ctx.throw
method should not remove response headers.
Koa@2.4.1 Node@8.9.3
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to make koa ctx.throw() use application/json rather than ...
throw () means any stacktrace is emitted to the server logs and also any custom error message is sent in the response. The...
Read more >Responses | Strapi Documentation
attributes - an object of values to use while setting the 'WWW-Authenticate' header. This value is only used when scheme is a string,...
Read more >Context - ThinkJS
Helper function to throw error When !value equals true , similar to ... If you don't want to use Koa's buildin response, just...
Read more >koajs/koa - Gitter
it's my first time using streams, so I'm a bit confused when should I iterate headers/status code? inside on('end') callback?
Read more >Back to Basics: Custom HTTP Response Header Manipulation ...
HTTP Headers are a core part of the HTTP protocol and while applications rarely need to deal with them, when you need to...
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
According to my usage, you also put it in the try block like this
Otherwise, there will be no header you set in the normal code.
Feel free to use https://github.com/ladjs/koa-better-error-handler.