CORS with Firebase+IONIC2+Angularjs: No 'Access-Control-Allow-Origin' still exists

廉价感情. 提交于 2019-12-25 09:17:25

问题


I read all the suggestions and also followed the ionic suggestion how to overcome the CORS issue and get rid of the error: Access-Control-Allow-Origin with no success. I think I am missing the exact path conversion in proxies:

The URL I am trying to access in firebase is: https://firebasestorage.googleapis.com/v0/b/Test1-xxxxx.appspot.com/o/userData.

My local host URL is: localhost:8100.

I don't understand how should I edit the path and proxyUrl settings in ionic.config.json:

{
"name": "Test1", 
"app_id": "", 
"v2": true, 
"typescript": true,

"proxies": [{

  "path": "...",

  "proxyUrl": "..."

}]}

I have tried many ways with no success, I am probably missing the point. I am new to Apps in general. I am starting with Web app using angular2+Ionic2


回答1:


Set proxy to

 "proxies": [
    {
      "path": "/v0",
      "proxyUrl": "https://firebasestorage.googleapis.com/v0"
    }
  ]

Then in your app you should call api as /v0/b/Test1-xxxxx.appspot.com/o/userData

Also this is a problem because when you compile it will call the same request meanwhile it should call firebase. So my recommendation would be to add constant BaseUrl and in dev it should be empty when you do production set it to "https://firebasestorage.googleapis.co" since when you bundle there is no proxy.



来源:https://stackoverflow.com/questions/40576037/cors-with-firebaseionic2angularjs-no-access-control-allow-origin-still-exis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!