I have a problem related to CORS and the needed headers.
Setup I run a angular project und angular-cli (localhost:4200) I want to access a via a HTTP-Request a JSON from a WebService. When I using the URL direct in the browser everything is fine and the JSON gets displayed. As soon as I send the request from my angular-app I get the following error:
XMLHttpRequest cannot load http://t00-holcim:8888/deliveries?fields=liefer_nr,dispo_nr,lieferscheinsta…r,empfaenger_nr,bestellinfo1,bemerkung&limit=3&deliveryNoteDate=2017-04-27. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 403.
Here's the program code:
.......
const headers = new Headers();
headers.append('Content-Type', 'application/json; charset=utf-8'); headers.append('Access-Control-Allow-Origin', '*');
const options = new RequestOptions({ method: RequestMethod.Post, headers: headers });
this.http.get(this.buildURLString(), options).map(this.extractData)
.subscribe((data) => {........}
I searched the net and I found that the error is related to CORS. Therefore I append to the header headers.append('Access-Control-Allow-Origin', '*'); but this does not help.
I got extension CORS for Chrome and enable "Enable cross origin resource sharing" but it didn't help.
Is this a configuration change on the server side or client side.