angularjs - Ionic - 跨源请求被阻止问题

标签 angularjs .htaccess cors ionic-framework

我已经使用 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 屏幕

Screen of Request & Response Header

请指导我启用 CORS 需要更改的任何配置。我们的服务器端框架是 Zend 1.x

最佳答案

跨源是由您的浏览器强制执行的,您当前的设置不应阻止从任何分布式手机运行应用程序。

要允许“服务于浏览器”应用程序与服务器之间的通信,请使用浏览器插件

Allow-Control-Allow-Origin: * Chrome Plugin做工作

关于angularjs - Ionic - 跨源请求被阻止问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27402818/

相关文章:

javascript - Angular JS Datatables 行单击事件添加动态 AngularUI 选项卡

javascript - 将 zip 文件返回到 angularjs 进行下载

javascript - Controller 方法在 AngularJs 中使用 Karma 调用 Jasmine 单元测试套件

javascript - 使用匿名函数和 $q promise 时的 AngularJS 'this' 问题

wordpress - htaccess 重写(旧域到新域,包括 www 和非 www)

php - 如何在浏览器 URL 显示中隐藏目录的索引页

javascript - 在 Three.js 中使用 OBJLoader 时出现 CORS 问题

php - Apache htaccess 选项 +FollowSymLinks 不再适用于托管公司 Hostgator

spring - Cordova POST - 请求禁止 403。未到达 Dispatcher Servlet

reactjs - 访问 XMLHttpRequest 被 CORS 阻止,请求的资源上不存在 'Access-Control-Allow-Origin' header ,仅用于 PUT 和 DELETE API