2016-06-13 102 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

相關問題