Hi, I’m trying to handle with CORS issues in livereload mode, but I wasn’t able to find a reasonable solution for that. My backend was developed in Java and it’s running on localhost.
Command:
ionic cordova emulate ios -l -c -s --address 127.0.0.1
ion.config.json
{
"name": "Smartmarket",
"app_id": "",
"type": "ionic-angular",
"integrations": {
"cordova": {}
},
"proxies": [{
"path": "/SmartmarketWeb/endpoint",
"proxyUrl": "http://127.0.0.1:8080/SmartmarketWeb/endpoint"
}]
}
Request example:
let headers = new Headers({
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
'Access-Control-Allow-Credentials': true,
'Access-Control-Allow-Headers': 'origin, content-type, accept'
});
let options = new RequestOptions({ headers: headers });
return this.http.post('http://127.0.0.1:8080/SmartmarketWeb/endpoint/login', json, options)
.timeout(TIMEOUT_REQUEST*1000)
.map(this.extractData)
.do(this.logResponse)
.catch(this.handleError);
Error:
Can anyone help me, please? I’ve tried to follow many solutions, however, none of them had an effect.