问题
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