skip to Main Content

I’m getting Firebase: Error (auth/unauthorized-domain) on localhost during google auth. I found that this error is caused when domain is not added to Authorized domains in Firebase. But when i checked Authorized domains there is localhost, and don’t know who is causing this error… Firebase screenshot

`

const signInWithGoogle = () => {
    const provider = new GoogleAuthProvider()
    signInWithPopup(getAuth(), provider)
        .then((result) => {
            console.log(result.user)
            router.push("/login")
        })
        .catch((error) => {
            console.log(error)
            alert(error.body + ": " + error.message)
        })
}

`

2

Answers


  1. As mentioned above, the url to visit is localhost/ not 127.0.0.1 as that is a different domain than localhost/ although it is effectively the same to your machine.

    Login or Signup to reply.
  2. If it is a Vite Project.
    Add
    1 . import dns from ‘dns’
    2 . dns.setDefaultResultOrder(‘verbatim’)

    command in vite.config.js

    run ”’ npm run dev ”’
    it will give you the link to localhost in your terminal to open your app and run it. It will work for sure.
    Many thanks for considering my request.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search