I'm trying to make Wildfly allow Cross-Origin requests, in order to be able to send requests to localhost using local JavaScript code.
Here's a request I'm making via JavaScript:
var request = new XMLHttpRequest();
request.open("GET", requestUrl);
request.setRequestHeader("Access-Control-Allow-Origin", "*");
request.send();
An error is thrown in the dev console when testing in Chrome.
XMLHttpRequest cannot load http://localhost:8080/.... Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response.
The request fails on Firefox as well, although no error is thrown in this case.
I modified my standalone.xml and restarted Wildfly according to this answer, to no avail:
CORS: AngularJS + Resteasy 3 + Wildfly
I even tried creating a filter class according to this answer, it didn't help as well:
How to enable Cross domain requests on JAX-RS web services?
I didn't change any configurations to include this class however, in case such a thing is required for it to work.