quickstart-js
quickstart-js copied to clipboard
CROS error when using getToken() for FCM token
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
i am facing the same issue. did you resolved it tho
I am struggling with the same issue. The error goes away, If I wait for few minutes and refresh the web application (which in turn raises a new fcm token request)