koajs / cors

Cross-Origin Resource Sharing(CORS) for koa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow not returning any access control headers if the Origin is not allowed to access the resource

mjarosie opened this issue · comments

Describe the feature

At the moment the library does not allow handling the scenario in which the origin is not allowed to access the resource: it expects options. origin to always return a string. That leads to developers having to come up with a "workaround" configuration (for example here or here) which is not ideal:

If the request Origin is not allowed, the middleware should be able to respond to pre-flight requests immediately with no Access-Control headers being returned at all.

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.

To set no Access-Control headers at all in the response, return an empty string "" from the options.origin function.