Closed nickpoorman closed 3 months ago
I added this package to solve the issue
https://github.com/lusever/koa-cors-error
It would be nice if this was mentioned in this package's documentation
Thanks @JoshZA ! I was also having this problem. It seems to be this behavior should be part of the main koa-cors
package, considering its not uncommon for an api server to desire throwing 403
's or 400
's as guard clauses to an api endpoint.
+1
Hi, Is this still an issue?
If an error is thrown by someone in the app, ie.
this.throw(400)
the headers are reset here: https://github.com/koajs/koa/blob/master/lib/context.js#L118 and the cors header is lost.Seems like this: https://github.com/evert0n/koa-cors/blob/master/index.js#L94 needs to be wrapped in a try catch and have the headers placed back in.