2016-06-13 124 views
2

我面临一个错误,我不知道该怎么做。每当我尝试使用下面的代码对用户保存到我的离子用户的服务:科斯请求被拒绝

Ionic.io(); 
var user = Ionic.User.current(); 
if (user.id) { 
    user.set('name', username); 
    //user.set('image',image_name); 
} 
user.save(); 

,然后我得到这个错误:

Ionic User: Error: CORS request rejected
XMLHttpRequest cannot load https://api.ionic.io/auth/users/null .
Response for preflight has invalid HTTP status code 404
OPTIONS https:// api .ionic .io /auth /users /null
[cors request rejected][1]
[coding][2]

+0

http://stackoverflow.com/questions/36002979/xmlhttprequest-cannot-load-and-response-for-preflight-has-invalid-http-status-co –

回答

1

离子具有科尔多瓦插件,挑选出调用的所有CORS问题“科尔多瓦 - 插件白名单”。当您通过浏览器进行测试时,Cordova插件不活跃,因此它不能解决您的问题。只有当您将应用程序部署到android/ios/windows时,Cordova插件才能正常工作。

相反,如果您想在浏览器上测试,则可以获得“Allow-Control-Allow-Origin”chrome插件以允许您发出请求。

+0

我仍在开发我的应用程序,我只是想在浏览器中运行它.. – user3728868

+0

好的。你知道怎么可以关于这个网址https://api.ionic.io/auth/users/null是NULL @TheAppchemist – user3728868

+0

我已经安装了Allow-Control-Allow-Origin插件到我的浏览器,但仍然收到错误,什么要做什么? – user3728868

相关问题