Authentification domain problem

Okay, so I’ve made a site using firebase studio and for logging I use firebase authentication, the problem is that I tried to change my auth domain in my site settings and configured domains so that when I click on google auth it redirect me to www.pedalezi.ro/__/auth instead of project.firebaseapp.com/__auth, the problem is that when the google auth generates the loging key I get a 404 error because the hosting doesn’t know to process it on my own domain instead of firebaseapp.com

1 Like

has this matter been resolved? Do you have other errors showing in the project as well? Could you please not include links to your personal projects? See the Documentation on Auth.

Hi @Dragos_Enache :waving_hand:

You’re really close — this is a common issue when switching Firebase Authentication to a custom domain.

Firebase’s built-in auth handler routes (like __/auth and __/auth/handler) are only automatically recognized on the default domain (project.firebaseapp.com). When you move to your own domain, you need to manually forward those routes so Firebase Hosting knows to process them.

Here’s how to fix it:

  1. In your project’s firebase.json, add a rewrite for the built-in auth handler:

    {
      "hosting": {
        "rewrites": [
          {
            "source": "/__/auth/**",
            "destination": "/index.html"
          }
        ]
      }
    }
    
    

    This tells Firebase Hosting to forward the __/auth requests to your app so Firebase Auth can complete the redirect flow.

  2. Re-deploy your site:

    firebase deploy --only hosting
    
    
  3. Make sure your custom domain is added and verified in your Firebase project under Authentication → Settings → Authorized Domains.

Once that’s done, the Google sign-in redirect will complete correctly on your custom domain.

Let me know if you still get the 404 afterward — sometimes clearing browser cache or running an incognito test helps confirm the redirect path is working.

Dragos, I can almost say that with a certainty this should fix your Error. However, let me know if a new error related to this one or if this one persists-doesn’t go away. If you are using external applications you will need to dump that applications cache, exit the application, and restart your device, and if working natively you may want to dump the cache, then restart the application from my workspace (…) click on to see the menu; select Restart and Ok.

Hello, I tried your method but as I found on internet is that this method works with Firebase Hosting but I am using Firebase App Hosting which is a bit different

Found the solution on this reddit Reddit - The heart of the internet