I am running a react project create with vite.
I want to implement authentication with firestore with google.
When I click to auth, the google login pop up appear and I receive in console CORS error.
This happen just on Chrome browser.
On Mozilla and Brave works fine.
const provider = new GoogleAuthProvider();
const auth = getAuth(firestoreInit);
const handleLoginWithGoogle = () => {
signInWithPopup(auth, provider)
.then((result) => {
// This gives you a Google Access Token. You can use it to access the Google API.
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential?.accessToken;
// The signed-in user info.
const user = result.user;
// IdP data available using getAdditionalUserInfo(result)
// ...
}).catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
});
console.log('login with google...')
}
I was looking online for some solutions, I was not able to find any.
2
Answers
There were some cookies issue. Once I cleared it, the cors issue disappeared.
Apparently the issue is still active if in google chrome I am logged in. In incognito works fine