markusahlstrand / cloudworker-proxy

An api gateway for cloudflare workers
MIT License
194 stars 22 forks source link

Better CORS handling #49

Closed danbars closed 4 years ago

danbars commented 4 years ago
  1. CORS preflight request is not identified by Origin header that can be sent in different non CORS events too. It is identified by OPTIONS method and Access-Control-Request-Method header
  2. Allow more fine grained control over CORS Access-Control-* headers using options.
  3. Allow handling OPTIONS request in this plugin and immediately return without calling next handlers (i.e. without calling a backend service)

If you like these changes I can also update the docs.

markusahlstrand commented 4 years ago

Thanks for the PR! The existing cors-header is very simplistic and I'm not certain exactly how it should work :) I'll ask questions in code comments to make sure I understand.

danbars commented 4 years ago

I'm going to commit the changes. Let me know if you think it's better

markusahlstrand commented 4 years ago

Looks good. Looks like the test for the cors handler needs to be updated and there might be some minor lint fixes. Could you check that the tests pass locally? Thanks!!

danbars commented 4 years ago

I will try to work on the tests and lint tomorrow.

markusahlstrand commented 4 years ago

Think it looks good now, just needs the test to pass. Let me know if you want me to help out.

danbars commented 4 years ago

Hi, sorry, I didn't get to it yet. I hope to get to it tomorrow.

danbars commented 4 years ago

Hi @markusahlstrand, finally got to complete this, sorry about the long delay. Lint and tests all pass + added new tests Also updated the readme with the new configuration.

markusahlstrand commented 4 years ago

Nice! Just waiting for the travis build to go through..

markusahlstrand commented 4 years ago

Merged, thanks for the PR!

danbars commented 4 years ago

Great, thanks for the project ;-)