CORS Problems

Hello everyone,
I’m trying to implement an ajax http request, but i’m heaving CORS issues with both Ionic Server and IOS.

Request method:

sendPostRequest(json, url) {

    var response;
    var headers = new Headers();
    headers.append('Content-Type', 'application/json');
    headers.append('Access-Control-Allow-Origin', '*');
    headers.append('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE,OPTIONS');
    headers.append('Access-Control-Allow-Headers', 'Content-Type');
    this.http.post('http://192.168.1.6:8080/restfull/'+url, JSON.stringify(json), {headers:headers})
    .map((res:Response) => res.json())
    .subscribe(
        data => console.log(data),
        err => console.error(err),
        () => console.log('done')
    );
    console.log(json);
}

Can anyone help me plz? I’d be grateful.

Easiest way for me is to use this nodejs corsproxy module.
https://github.com/gr2m/CORS-Proxy :slight_smile:

Ty for your answer, and what about IOS and Android, do you have any idea how to deal with it?