using localhost domain in firebase emails

67 views Asked by At

Following the docs for Authenticate with Firebase Using Email Link in JavaScript, I have node running locally in windows. I am able to login with email and password fine, however the email link method is failing. I have this config:

const actionCodeSettings = {
    url: 'http://localhost:5173/',
    // This must be true.
    handleCodeInApp: true,
    iOS: {
        bundleId: 'com.example.ios'
    },
    android: {
        packageName: 'com.example.android',
        installApp: true,
        minimumVersion: '12'
    },
        dynamicLinkDomain: 'localhost'
    };

and

sendSignInLinkToEmail(auth, email, actionCodeSettings)
     .then(() => {
         window.localStorage.setItem('emailForSignIn', email);
     })
     .catch((error) => {
         const errorCode = error.code;
         console.error(error.code);
         const errorMessage = error.message;
         setText(error.message);
     });

localhost is listed in Authorised domains yet still getting error: invalid-dynamic-link-domain

I have tried changing both url and dynamicLinkDomain in actionCodeSettings, arbitrarily to different domains. Not sure what is causing the issue here.

EDIT: I have tried the following:

const actionCodeSettings = {
    url: 'http://localhost:5173/',
    // This must be true.
    handleCodeInApp: true,
    };

Which will send the email, although the link URL is a .firebaseapp.com domain. I have also seen this example on YouTube, although I can't see how mine differs.

1

There are 1 answers

0
Bringle On

Found! URL used in emails is set from the console.

Authentication -> Templates -> Edit Template -> Customise Action URL.