Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS Middleware help #908

Open
josh2112 opened this issue Jul 13, 2022 · 0 comments
Open

CORS Middleware help #908

josh2112 opened this issue Jul 13, 2022 · 0 comments

Comments

@josh2112
Copy link

Please forgive the question, as I'm sure this is just a misunderstanding I have about CORS or Hug middleware...

As I understand it, a request involving CORS is actually two requests:

  1. A preflight request, using the OPTIONS method, where the server tells give us permission to make the 'real' request along with some headers.
  2. The actual request.

I've been having a problem with duplicate requests in one of my Hug APIs. It seems like the built-in CORS middleware is adding the appropriate headers to the OPTIONS request, but then passing it on through to the API. The client then gets the OPTIONS response and sends the real requests, which results in the same operation being performed twice in my API.

It is my understanding that a CORS middleware should entirely handle the OPTIONS request, sending a response itself and not passing it on to any other middleware or the API.

Is there a reason the Hug CORS middlware doesn't do this, and is there an easy way to accomplish it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant