Пишу на ionic 2. Послаю запрос так:
let headers = new Headers({
'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'
});
let options = new RequestOptions({
headers: headers,
withCredentials: true,
});
this.items = 'l='+credentials.lgn+'&p='+credentials.pwd;
this.http.post(this.apiUrl+credentials.sch + '/login', this.items, options)
.map(res => res.json())
.subscribe(data => {
console.log(data);
Полчаю:
XMLHttpRequest cannot load
edu.uray.ru:8082/5/login. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '
localhost:8100' is therefore not allowed access.
В ответе от сервера в "инструментах разработчика" в браузере ответ получен.
Request URL:
edu.uray.ru:8082/5/login
Request Method:POST
Status Code:200 OK
Remote Address:93.171.9.26:8082
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Content-Encoding:gzip
Content-Length:51
Content-Type:text/plain; charset=UTF-8
Expires:-1
Request Headers
view source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate
Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:25
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:_ga=GA1.2.1622162271.1491933795; _ym_uid=1491933807942985410; __utmt=1; __utma=195415288.1622162271.1491933795.1492002394.1492089338.3; __utmb=195415288.1.10.1492089338; __utmc=195415288; __utmz=195415288.1491934415.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Host:edu.uray.ru:8082
Origin:
localhost:8100
Referer:
localhost:8100
User-Agent:Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Mobile Safari/537.36
Как обойти No 'Access-Control-Allow-Origin' . Доступа с серверной части нету. все решения что нашел были добавлением CROS на сервере.