I have my Ionic2 app hosted on Firebase. What I need is to get external data from an API service where
No 'Access-Control-Allow-Origin' header is present on the requested resource
I can work around it locally by using proxies in ionic.config.json file:
"proxies": [
{
"path":"/api",
"proxyUrl": "https://api.somwhere.com/"
}
]
But I have no idea how to deal with this after deploying my app to Firebase. Is it somehow possible?
The Firebase docs have an example of setting the Access-Control-Allow-Origin
in your firebase.json
to allow cross-origin requests for font files. You could adjust that like this:
"headers": [ {
"source" : "**",
"headers" : [ {
"key" : "Access-Control-Allow-Origin",
"value" : "*"
} ]
}
That will allow cross-origin requests for all resources. Of course if you want to restrict it to specific resources, you can adjust the source
value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With