-
Notifications
You must be signed in to change notification settings - Fork 926
CORS error when using getToken() for FCM token #8976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Hi Team, Do you have any updates on this? We are still facing this issue, and our customers keep on reporting that the notification is not working |
Hey @Rafi2798 taking a look at your issue, if what you say here,
Is correct, I'm 99% sure your configuration is incorrect, specifically your projectId. That URL is generated from https://github.com/firebase/firebase-js-sdk/blob/main/packages/installations/src/functions/common.ts#L33, from
but, per your URL, that says your projectId is Are the rest of your fb services working right with that projectId? Tbh, I can't believe that they are. |
As @seaders explained, your projectId seems to be malformed, likely containing a URL rather than a project ID string. Additionally, using FCM and service workers requires a secure context, so you must serve your application over HTTPS ( |
Hi @seaders / @dlarocque We have already debugged the code and ensured the configurations are correct. Please find the screenshots below I guess your side missed adding this header, "Access-Control-Allow-Origin" is restricting requests in the browser. Could you please check and provide the solution ASAP?. our customers keep on escalating this issue... Regards, |
@Rafi2798 |
Operating System
Windows and MAC
Environment (if applicable)
Angular
Firebase SDK Version
11.6.0
Firebase SDK Product(s)
Messaging
Project Tooling
Firebase: 11.6.0
Angular: 18.2.6
OS: Windows and MAC
Browser: All
Detailed Problem Description
The above code gives me an error in the console. My web application is hosted under this baseHref ("/agent"), and the service worker file (firebase-messaging-sw.js) is also located under this root ("/domain/agent").
Access to fetch at 'https://firebaseinstallations.googleapis.com/v1/projects/https://crm-pu.firebaseio.com/installations' from origin 'http://ribaac.com' 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.
Steps and code to reproduce issue
The text was updated successfully, but these errors were encountered: