A
A
Alexander Sukharev2017-03-30 13:24:50
JavaScript
Alexander Sukharev, 2017-03-30 13:24:50

Ionic 2 how to do cross domain request?

I am writing in ionic 2. I will send a request like this:

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);

I get:
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.
In the response from the server in the "developer tools" in the browser, the response is received.
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
How to bypass No 'Access-Control-Allow-Origin' . There is no access from the server side. all the solutions I found were adding CROS on the server.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Shilov, 2017-04-05
@tabbols95

As the question is formulated, so I will formulate the answer.

My answer
JSON

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question