I try to create an http post like this:
getData()
{
let headers = new Headers({"Content-Type":"application/json; charset=UTF-8",
"Accept":"application/json",
"Access-Control-Allow-Origin" : "*",
'Allow-Control-Allow-Origin': '*'
});
return this.http.post(url, body, { withCredentials: true,
headers: headers
})
.map(res => res.json())
.toPromise();
}
And got this error:
XMLHttpRequest cannot load http://example.org/getData. Response to preflight request doesn’t pass access control check: The value of the ‘Access-Control-Allow-Origin’ header in the response must not be the wildcard ‘*’ when the request’s credentials mode is ‘include’. Origin ‘http://localhost:8100’ is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Another requests are working with these two chrome extensions: Moesif Origin & CORS Changer or Allow-Control-Allow-Origin: *. But when is set withCredentials true i get error.
I try to add proxy in to ionic.config.json file like this:
“proxies”: [
{
“path”: “/”,
“proxyUrl”: “http://example.org”
}
]
but nothing happened, then i changed the wildcards to http://localhost:8100/ and/or the site address, but it’s didn’t work too. The server allow everything, the problem is the chrome preflight. I read the forums for two days, and I out of ideas, please help.Preformatted text