Search code examples
firebasehttp-redirectfirebase-hosting

force redirecting default firebase domain to custom domain


is it possible to redirect example.firebaseapp.com to example.com? I don't want visitors to access the default firebase domain.


Solution

  • You could perform a client side redirect with JavaScript.

    if (location.host === 'example.firebaseapp.com') {
      location.href = 'https://example.com';
    }
    

    You'll want to think about retaining the path, query string, and fragment as well.