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

Using http filter config is disabling CORS options #38155

Closed
ia3andy opened this issue Jan 12, 2024 · 9 comments · Fixed by #38185
Closed

Using http filter config is disabling CORS options #38155

ia3andy opened this issue Jan 12, 2024 · 9 comments · Fixed by #38185
Assignees
Labels
Milestone

Comments

@ia3andy
Copy link
Contributor

ia3andy commented Jan 12, 2024

Describe the bug

When using a filter, it doesn't add the CORS headers anymore.

quarkus.resteasy-reactive.path=/api

quarkus.http.filter.api.header."X-Content-Type-Options"=nosniff
quarkus.http.filter.api.header."X-Frame-Options"=deny
quarkus.http.filter.api.header."Strict-Transport-Security"=max-age=31536000; includeSubDomains
quarkus.http.filter.api.header."Content-Security-Policy"=default-src 'none';
quarkus.http.filter.api.matches=/api/.+
quarkus.http.filter.api.order=1

quarkus.http.cors=true
quarkus.http.cors.origins=/.*/

Expected behavior

The cors headers (or any header that is set up elsewhere) should be added in addition to the other headers

Actual behavior

The cors headers are removed

How to Reproduce?

Clone this and start https://github.com/ia3andy/reproducer-cors with quarkus dev

Use this in you browser console (on a tab with a different domain opened):

fetch("http://localhost:8080/api/hello").then(r => r.text()).then(console.log)

It fails with CORS error.
Remove the filter from the properties and it works.

image

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

3.5+

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@geoand
Copy link
Contributor

geoand commented Jan 12, 2024

Use this in you browser console:

In any page, or some specific one?

@ia3andy
Copy link
Contributor Author

ia3andy commented Jan 12, 2024

any page

@geoand
Copy link
Contributor

geoand commented Jan 12, 2024

I tried with Chrome and it only worked on localhost:8080 whether the filter was active or nor

@ia3andy
Copy link
Contributor Author

ia3andy commented Jan 12, 2024

Ok so sorry, I thought it was any page but no, you need to test it from a page with another domain:
image

On the screenshot, first request is with the filter, the second without.

Here is a better command for the test:

fetch("http://localhost:8080/api/hello").then(r => r.text()).then(console.log)

I've updated the instruction to reproduce..

@ia3andy
Copy link
Contributor Author

ia3andy commented Jan 15, 2024

cc @sberyozkin

@ia3andy
Copy link
Contributor Author

ia3andy commented Jan 15, 2024

@geoand did you reproduce?

@ia3andy
Copy link
Contributor Author

ia3andy commented Jan 15, 2024

this is a nasty bug

@geoand
Copy link
Contributor

geoand commented Jan 15, 2024

Yeah, I'll have a fix soon

geoand added a commit to geoand/quarkus that referenced this issue Jan 15, 2024
The previous behavior would completely replace
existing response headers

Fixes: quarkusio#38155
@sberyozkin
Copy link
Member

Thanks @ia3andy @geoand, I was on PTO

geoand added a commit to geoand/quarkus that referenced this issue Jan 15, 2024
The previous behavior would completely replace
existing response headers

Fixes: quarkusio#38155
geoand added a commit that referenced this issue Jan 15, 2024
Make sure `quarkus.http.filter` headers don't remove existing headers
@quarkus-bot quarkus-bot bot added this to the 3.7 - main milestone Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants