CORS issue in ionic4

I am using Angularfire 2 and calling cloud function from my ionic 4 app.How to solve the following CORS issue in ionic 4 ??

Access to fetch at ‘https://null-myionicshop-693bc.cloudfunctions.net/subscribeToTopic’ from origin ‘http://localhost:8100’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

Have a look at
https://www.joshmorony.com/dealing-with-cors-cross-origin-resource-sharing-in-ionic-applications/

Late to the discussion, but in case anyone else with a similar issue stumbles upon this …It’s not actually the CORS policy that’s the problem, you shouldn’t be connecting to a null-… address. FunctionsRegionToken needs to be imported along with the AngularFireFunctionsModule in app.module and then added to the providers array with the region id you’re using: { provide: FunctionsRegionToken, useValue: }

1 Like