Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic - Cross-Origin Request Blocked Issue

I have setup the Ionic development environment using Yeoman generator (https://github.com/diegonetto/generator-ionic). Everything is works well.

The problem is on Sever side request, I am getting the Cross-Origin Request Blocked error.

I add below link in .htaccess file and AngularJS app.js, still getting 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;

Error Message I am getting 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.

Screen of Request & Response Header

Screen of Request & Response Header

Please guide me any configuration need to be changed for enabling CORS. Our server side framework is Zend 1.x

like image 274
Muthamizhchelvan. V Avatar asked Dec 20 '22 08:12

Muthamizhchelvan. V


1 Answers

The cross origin is forced by your browser, running the application from any distributed phone should not be blocked with your current settings.

To allow communication between your "served to browser" app to your server use a browser plugin

Allow-Control-Allow-Origin: * Chrome Plugin do the work

like image 154
Ben Diamant Avatar answered Jan 03 '23 07:01

Ben Diamant