Ionic - request for cross-request with blocking

I installed the Ionic development environment using the Joman generator ( https://github.com/diegonetto/generator-ionic ). Everything works well.

The problem is the request on the Sever side, I get an error with the request for cross-request.

I am adding the link below to the .htaccess file and AngularJS app.js, still getting the same error

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers: Authorization

AngularJS Provider

$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
$httpProvider.defaults.withCredentials = true;

The error message I get is

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at 
http://192.168.1.18/tracker/user/login. 
This can be fixed by moving the resource to the same domain or enabling CORS.

Request and Response Screen

Screen of Request & Response Header

Please indicate which configuration must be changed to enable CORS. Our server side structure - Zend 1.x

+4
source share
3 answers

.htaccess, , , Google Chrome "*", URL

Header set Access-Control-Allow-Origin "http://localhost:8100"
Header set Access-Control-Allow-Credentials: true
+1

Zend Ionic, IIS REST API Ionic.

For me, I had to add, in addition to what you already have, "Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS".

After adding the "allow methods" header, I was able to fully use my API.

If this does not work out for you, report back and I will dig a little deeper in my project to find out if I forgot to change the client side, which was also necessary.

0
source

All Articles