我已经使用 Yeoman 生成器设置了 Ionic 开发环境 ( https://github.com/diegonetto/generator-ionic )。一切都运转良好。
问题出在服务器端请求上,我收到跨源请求被阻止错误。
我在 .htaccess 文件和 AngularJS app.js 中添加以下链接,仍然遇到相同的错误
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers: Authorization
AngularJS 提供者
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
$httpProvider.defaults.withCredentials = true;
我收到的错误消息是
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.
请求和响应 header 屏幕
请指导我启用 CORS 需要更改的任何配置。我们的服务器端框架是 Zend 1.x
最佳答案
跨源是由您的浏览器强制执行的,您当前的设置不应阻止从任何分布式手机运行应用程序。
要允许“服务于浏览器”应用程序与服务器之间的通信,请使用浏览器插件
关于angularjs - Ionic - 跨源请求被阻止问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27402818/