Ionic - 凭证标志为true时,不能在'Access-Control-Allow-Origin'标头中使用通配符'*'

时间:2015-08-09 12:43:02

标签: angularjs ionic

我需要在我的应用中为我的http请求存储Cookie,因此我设置$httpProvider.defaults.withCredentials = true;

但是,在设置此项时,我在执行http requeust时遇到错误:

A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:8100' is therefore not allowed access.

我相信此错误不会在设备上显示,但我想使用我的电脑的网络浏览器调试应用程序。我尝试配置我的config.xml并将访问源设置为localhost:8100,但它也不起作用。

我也使用Chrome的Allow-Control-Allow-Origin:*但也没有运气。

1 个答案:

答案 0 :(得分:3)

正确,当您在移动设备上作为应用程序运行离子应用程序时,或在模拟器中,CORS限制不适用。

您可以使用--disable-web-security标记在Google Chrome中停用这些限制。见https://stackoverflow.com/a/6083677

此标志确实会降低您的浏览器安全性,因此我只会在开发您的应用程序时将其禁用,并在执行任何其他网络浏览之前重新启动没有标记的Chrome。

相关问题