Reputation: 41
In my AngularJs Application, I get a cross-origin-error when Angular enters a rest interface (using chrome and IE11)
What you see in the chrome console:
XMLHttpRequest cannot load localhost:9080/user/api/whoami.
Cross origin requests are only supported for protocol schemes:
http, data, chrome, chrome-extension, https, chrome-extension-resource.
On serverside, the rest interface is implemented with camel:
restConfiguration()
.enableCORS(true)
.corsHeaderProperty("Access-Control-Allow-Headers", "Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers")
.corsHeaderProperty("Access-Control-Allow-Origin","*")
.component("servlet")
.bindingMode(RestBindingMode.json)
.dataFormatProperty("prettyPrint", "true");
This question isalready asked here but always deals with files loaded locally.
As local applicationserver Jboss is used (9080) For the frontend Angular is used (8080) I even do not understand why a cross-origin-request is existent
Upvotes: 1
Views: 1253
Reputation: 41
The Appication is not able to connect to an adress named localhost, thus the error message says
Cross origin requests are only supported for protocol schemes: http, ...
Changing the interface to http://localhost... and it's all fine
Upvotes: 3