firebase / firebase/quickstart-js

CROS error when using getToken() for FCM token

Open
#499 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.4k
Forks
3.7k
Avg merge
2d 13h
Merged PRs (30d)
6

Description

firebase: 8.0.0
react: 16.12.0
OS: windows
browser: chrome

```
const msg = firebase.messaging();
Notification.requestPermission().then(() => {
return msg.getToken()
}).then((data) => {
console.log('token', data)

})
```

above code gives me error on console

**Access to fetch at 'https://firebaseinstallations.googleapis.com/v1/projects/https://crm-pu.firebaseio.com/installations' from origin 'http://localhost:3000' 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.**

Even when I deploy my react app in Heroku the error remain the same. I registered firebase-messaging-sw.js service worker even receive local notification through showNotification() but when I try to get FCM token it gives error of CORS

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.