I spent about 20 hours trying to solve this problem and reading numerous posts. The quick answer is to change the processing of the CORS server and avoid perches. The following code works on tom ee (possibly others), but not on glass fish.
@Provider public class NewCrossOriginResourceSharingFilter implements ContainerResponseFilter { @Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext response) { response.getHeaders().putSingle("Access-Control-Allow-Origin", "*"); response.getHeaders().putSingle("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE"); response.getHeaders().putSingle("Access-Control-Allow-Headers", "Content-Type"); } }
Changing the code line by line, I found that adding a call to "Access-Control-Allow-Headers" throws an exception in the glass shawl, which leads to an internal server error (500). Apparently, the exception has existed for more than a year and does not show any signs of correction.
I could never get the proxy-config solution to work. I saw debugger messages about the impact
/api/path/users => http:localhost:8080/
It seems that any trailing path or query parameters are truncated by a proxy filter.
Hope this saves someone a ton of time.
source share