Я сначала опишу проблему и поведение, а затем расскажу о том, что я пробовал до сих пор, а затем покажу код. Установлены инструменты Firebase, включая эмуляторы, и я добавляю Google Signin. Похоже, поведение заключается в том, что как signInwithredirect и signwithpopup действительно хотят использовать https для своих URL -адресов, и ничего, что я могу сделать, не убедило их сделать иначе. Это приводит к ошибкам для того, чтобы сказать мне, что они не могут установить безопасное соединение (либо в перенаправлении, потому что оно пытается перенаправить на https: // localhost: 5173/, или он хочет всплыть на iframe и назначить URI iframe https: // localhost: 5173). Хост и порт соответствуют тому, что работает мой проект, конечно. I may be forgetting some, but the most obvious ones include:
[*]Ensuring that my Google OAuth project has whitelisted http://localhost:5173 as both a source and redirect URI
[*]Ensuring that Firebase is connected to that Google Oauth project
[*]Ensuring that my .env.local has an entry for the auth_domain to be overridden and that it's successfully being overridden (though, note if I try and add the protocol it strips out the : so that it becomes https://http//localhost:5173/...)
Trying to pass the Auth emulator URL as a string to the signInWith() function as Описанный в одном из документов Firebase, которые я обнаружил, это привело к ошибке аргумента AUTH Firebase, и, рассматривая фактическую документацию API, она не выглядит поддержкой (или, если это не так задокументировано). /> < /ul>
code < /strong> < /p>
Код, который я пробовал в обоих направлениях, но здесь вы: < /p>
Код: Выделить всё
const auth = getAuth(app);
const provider = new GoogleAuthProvider();
console.log(import.meta.env.VITE_FIREBASE_AUTH_DOMAIN)
// signInWithRedirect(auth, provider)
// .then((result) => {
// console.log(result)
// }).catch((err) => {
// console.log(err.message)
// });
signInWithPopup(auth, provider)
.then((result) => {
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
const user = result.user;
console.log(JSON.stringify(user));
}).catch((error) => {
console.error(error.message);
})
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/796 ... -localhost