-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
router not setting ContextKeyHeaderAllow for group, causing cors preflight to not work #2573
Comments
Hi, sorry for late reply but I think problem is not with router. You example is missing If there would be x@x:~/$ curl --location --request OPTIONS 'http://localhost:8092/api/test' -v -H "Origin: http://test.test"
* processing: http://localhost:8092/api/test
* Trying [::1]:8092...
* Connected to localhost (::1) port 8092
> OPTIONS /api/test HTTP/1.1
> Host: localhost:8092
> User-Agent: curl/8.2.1
> Accept: */*
> Origin: http://test.test
>
< HTTP/1.1 204 No Content
< Access-Control-Allow-Headers: Origin,Content-Type,Accept
< Access-Control-Allow-Methods: GET,HEAD,PUT,PATCH,POST,DELETE
< Access-Control-Allow-Origin: *
< Vary: Origin
< Vary: Access-Control-Request-Method
< Vary: Access-Control-Request-Headers
< Date: Tue, 06 Feb 2024 06:06:27 GMT
<
* Connection #0 to host localhost left intact |
but I do admit that but For example this panics: curl --location --request POST 'http://localhost:8092/api/test' -v -H "Origin: http://test.test" |
Ok yes removing the nil (for middleware) solves the problem, with my test code sample. My actual code however does not pass a nil but uses a keycloak middleware, and I still have a problem. Apologies for my poor sample. |
Ok it looks like the issue is when passing a middleware to the group.
curl --location --request OPTIONS 'http://localhost:8092/api/test' -v -H "Origin: http://test.test" returns the following when a middleware is passed in < HTTP/1.1 204 No Content when the middleware is removed then it returns < HTTP/1.1 204 No Content |
I'm quite sure this caused by hidden routes that group middlewares add. This is very old hack to make sure that group middlewares are applied to 404 cases. Which we can not remove as there are plenty of people "using" that feature. Lines 22 to 33 in 88c379f
|
Issue Description
Checklist
Expected behaviour
curl --location --request OPTIONS 'http://localhost:8092/api/test'
--data ''
should return
Allow: OPTIONS, POST
Vary: Origin
Date: Fri, 05 Jan 2024 12:42:24 GMT
Actual behaviour
returns
Vary: Origin
Date: Fri, 05 Jan 2024 12:42:24 GMT
not reaching this code in router
instead it is going into this code above
Steps to reproduce
Working code to debug
Version/commit
v4.11.3 and v4.11.4 (only 2 tested)
The text was updated successfully, but these errors were encountered: