CORS protection active when same-origin
See original GitHub issueDescribe the bug Trying to make a frontend work by using your API but i keep getting rejected because CORS Filters are still active.
ApiServer == localhost:3455 HttpServer Frontend = localhost:1234
Because its the same domain and CORS is active i get “Same-Origin” CORS back
I tried to overwrite your ApiServer class to make it work but this undertow-cors-filter is garbage and not working.
They found a solution here:
https://stackoverflow.com/questions/42066845/how-to-enable-access-control-allow-origin-in-undertow
but that would mean i have to overwrite your AbsSessionHandler.class . At that point i gave up otherwise i needed to rewrite your whole API 😛
Could you please add this to your AbsSessionHandler.class :
exchange.getResponseHeaders().put(new HttpString("Access-Control-Allow-Origin"), "*"); exchange.getResponseHeaders().put(new HttpString("Access-Control-Allow-Methods"), "GET, POST, PUT, DELETE"); exchange.getResponseHeaders().put(new HttpString("Access-Control-Allow-Headers"), "*");
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (12 by maintainers)
Top GitHub Comments
I don’t think I will accept a rewrite of the API. Undertow allows for a much larger level of flexibility (in my opinion) and the API is very lightweight.
Allowing any origin is just fine.
Hi lkwg82 ,
That would be a integration test than, because with a normal JUnit test is nothing to test. We would need to install a Rest client like Rest Assured and run a server and check the response if the Allow Origin is in the response. Thats quite a lot of work and at least 3 more test packages in pom for such a small task. I made a manual test instead and checked if it works