0

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

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Sami Koren
  • 53
  • 7

1 Answers1

3

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.

Vova Bilyachat
  • 18,765
  • 4
  • 55
  • 80
  • Thank you very much, I struggled this for 3 days! Now it is working! and also I will take your advise regarding BaseUrl. Thanks again! – Sami Koren Nov 14 '16 at 16:26
  • In the code, How would you differentiate between the code running via ionic serve...and the code running in firebase? – Mike K. Nov 09 '17 at 05:51
  • 1
    @MikeK. Environments or if you are not building native app but progressive then always call /api/myactiton so it will send request to the same domain – Vova Bilyachat Nov 09 '17 at 05:53
  • @VolodymyrBilyachat I am building a progressive app, and right now have only been testing it in the web (locally and deployed to firebase). If my local app calls /api/foo-bar that is fine, since I can use the proxies and have it point to a different URL. But when I'm on firebase, the proxy stuff doesn't work... so wouldn't the APIs then go out to www.my-app.firebase.com/api/foo-bar? Then that wouldn't find anything and return a 404. – Mike K. Nov 09 '17 at 15:02