O
O
Oleg46152017-08-08 22:53:58
CORS
Oleg4615, 2017-08-08 22:53:58

Swagger using api, requests give: "...No 'Access-Control-Allow-Origin'...Origin 'null' is therefore not allowed access" what to do?

The employer gave a test task: write the client part for Api and gave a link to swagger.
the point is:
I am writing a request to the address

$http({method:'POST', url:'http://frontendtest.xrm.ru/api/Sessions'})
            .success(function(result){
                return result;
            })
            .error(function(err){
                console.log('session not get',err);
            })

and get a response with code 200
XMLHttpRequest cannot load http://frontendtest.xrm.ru/api/Sessions. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Googled that the problem is in cross-domain requests in browsers. while I see the proposed solution in doing communication through my server, I would not want to spend time on this, and I think there are still easier ways.
and time is running out, help..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
First Last, 2017-08-08
@Oleg4615

Simpler ways:
On the server ( frontendtest.xrm.ru which) implement CORS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question