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 with Ajax is not working well. #3312
Comments
Do you have to go the cors route? I'd just configure npm (vuejs) to proxy anything on localhost:8084/person to localhost:8080/person. In production on kubernetes this sort of thing is better done with an 2 ingresses sharing same dns. Edit: if you staying with cors, try using your real ip, I've had trouble with localhost in the past |
I took a look and it seems this is caused by the way how the CORS servlet filter and the RESTEasy servlet filter interact. I'll continue digging on Monday. |
That makes sense now. Because request is not being reached to quarkus request filter so it must be stopped by some earlier stage. Thanks for the update. |
Found two more strange scenarious:
For some reason PATCH requests are not catched by ContainerResponseFilter at all. |
Ad 1., that's because the CORS servlet filter expects to find the value of the Ad 2., that's probably also because the |
Ad 1. again: the CORS filter already allows all origins, if |
Is this still a WIP? Just doing a check-in to see if there is something in motion (npm dev UI environment with quarkus dev backend environment). The scenario I have is a quarkus w/ undertow, resteasy, and smallrye-openapi and using Postman not getting any of the CORS-associated headers in the response for the rest/openapi endpoint (no Access-Control-Allow-Origin header entry). Tested quarkus 0.20.0 and 0.23.1 application.properties
|
I have tried the last version 0.23.1 but it doesn't work: Back-end still rejects requests from a different domain, respectively my react Front-end app still receive |
I'm testing CORS using http://www.test-cors.org on Quarkus 0.23.2 and also the latest
It seems to work just fine. |
Just tested 0.23.2, hopefully I'm the minor but still not getting the Access-Control-Allow-Origin headers (tested both mvn quarkus:dev and a production build running the java -jar *-runner.jar). application.properties
|
@dhartford Can you please provide more details? For example, do you have a reproducer using Also, do you perhaps use some kind of a caching proxy or something similar? I've noticed that the Quarkus CORS handler should at the very least include |
Using postman and curl for direct functional testing, and 'npm start' with a webapp with a fetch for applied testing (which states the no Access-Control-Allowed-Origin header problem), all localhost or 127.0.0.1 without any caching proxy. curl -v http://localhost:8080/openapi/app
|
Ah, so it's on the OpenAPI endpoint, I didn't try that. I'll check tomorrow, thanks for the info. |
Dears, Quarkus : https://github.com/iabughosh/microprofile-health I will do some debugging from my end too. Regards. |
The same issue is still produced as @dhartford describe, even with the latest version 0.23.2 |
I have the same issue as well. When I use quarkus.http.cors.origins=http://localhost:8081 is working fine. But when using * quarkus.http.cors.origins="*"` is not working no matter what I do. |
Instead of One other thing I'd like to highlight, because I've seen it in the reports here (I already mentioned this in the other CORS issue): if the request doesn't have the This is perfectly fine per my understanding of CORS. (What's worse is that this doesn't necessarily play well with caching proxy servers. My understanding is that we should at least always include |
@Ladicek you are right. It is working now only with: quarkus.http.cors=true |
Dears, |
Does anyone here have a reproducer with a ReactJS application accessing a Quarkus REST API to demonstrate this error to maintainers? |
@iabughosh I think, this issue should be marked as solved.
|
Unfortunately, the main problem - which is disabling the cors still not working fine. I will try these configuration and report back. |
Just Tried @Ladicek and it is working fine (which is great :) ); however, it is not working if I disabled CORS. I will close this bug as the main issue is resolved for me. |
As I said, the only way to make it work on any domain is using only one single CORS property: quarkus.http.cors=true If I disable it, the problem still persists. I'm using Quarkus 0.25.0. |
Currently, you can achieve "all origins" by simply omitting |
@Ladicek For the |
@dhartford In that case, it should be possible to just write |
I have same issue..i have tried all above ways.but still not work.issue is still there of cors |
in case you are working with a yaml file this must be your configuration : |
Calling REST resources using Ajax is not working fine
I am trying to call a service sides on my localhost:8080/person (POST) through VueJS app on my localhost:8084 but it is not working. I tried to enable CORS config. in application.properties with the below :
Expected behavior
It should work fine and be able to call my resource.
Actual behavior
Browser logs error :
Even it is not reaching to my ContainerRequestFilter code.
To Reproduce
Steps to reproduce the behavior:
Configuration
Environment (please complete the following information):
uname -a
orver
: Darwin SDG0268LMAC 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64java -version
: OpenJDK Runtime Environment Corretto-8.202.08.2 (build 1.8.0_202-b08)Additional context
Event if CORS is disabled same issue is produced.
The text was updated successfully, but these errors were encountered: