19

I'm new to firebase and I Want to know how to customize action URL for the password reset and email verification mail.

For Example https://app.firebaseapp.com/__/auth/action // here I Don't want firebaseApp.com. So how to do I Customize this action URL from firebase.? Please help me as I am new to firebase. any help would be appreciated

9 Answers 9

14

if you want to change or customize default action firebase URL: https://app.firebaseapp.com to https://your_domain.com.

You just need to create a Firebase Dynamic link of your custom domain or part of your website and you're done. After Creating Firebase Dynamic Link, go to Authentication/Templates on Firebase, and click on Customize URL of your action link and type your Dynamic Link and hit done. Your Default Action URL link has been changed.

More information please visit https://firebase.google.com.

4
  • 2
    This is the correct answer. There's no need to build a custom handler website if you only want to change the domain from firebaseapp.com to yourdomain.com (as long as you keep the rest of the path the same, of course: https://yourdomain.com/__/auth/action?mode=<action>&oobCode=<code>). This also changes the domain in the URL returned by admin SDK calls like admin.auth().generatePasswordResetLink(email)
    – maganap
    Aug 10, 2020 at 13:07
  • 4
    I don't think this is correct. see stackoverflow.com/questions/59503951/…
    – kimbaudi
    May 13, 2021 at 18:45
  • 1
    all of you are correct in a way ha. Seems the answer is correct when you're using Firebase Hosting for yourdomain.com however if you're not doing that, then you will have to implement all the handlers based on the docs described here: firebase.google.com/docs/auth/custom-email-handler Sep 19, 2022 at 2:53
  • 1
    Seems like firebase dynamic links are being deprecated, is there a way to do this without them?
    – alvitawa
    Sep 15 at 9:00
8

I believe i've found a way to accomplish this without the need to create your own webpage.

First go to your Firebase Console and then Firebase Hosting. Create a unique subdomain like verify.yourdomain.com or app.yourdomain.com. Redirect that domain to your project's default domain.

verify.yourdomain.com redirects to default-1234.firebaseapp.com.

Once Firebase verifies your subdomain after some time, it should be labeled as connected. Then within the console go to Authentication and then Templates. Replace the default domain within the action handler to your new subdomain.

https://verify.yourdomain.com/__/auth/action.

That should be it.

0
7

I know it's an year old question now, but this is the correct answer. Custom Email Handler Docs. Simply customizing that URL wont help as it's just half of the work.

3
  • This is not correct. You can simply customise the URL. Aug 24, 2022 at 17:23
  • 1
    No you cannot customise the URL, please provide an actual example, if you really think you can. OP is asking to customise the action url, not the domain (if that's what you're referring to).
    – Eduard
    Aug 25, 2022 at 18:02
  • It's as described here: stackoverflow.com/a/57206519/247451 I'm interpreting the OP's request of "change URL" as "add a domain name" - not "build my own site". Aug 26, 2022 at 17:43
7

I don't know if there is any drawbacks with this (it's working for me), but the simplest way, if you are already using a custom domain in your app, is to just change the domain in the custom URL in the email template.

For example, just change https://myapp.firebaseapp.com/__/auth/action to https://myapp.com/__/auth/action in the template configuration, considering that you have already configured myapp.com to be your custom domain in firebase hosting.

No need for dynamic links, redirects or even to create a subdomain in your DNS!

3
  • @DenysMedvediev did you keep the "/__/auth/action" part in the end of the new URL? Sep 26, 2021 at 19:14
  • 2
    This is the easiest and works for me. Just to expand on the answer, any domain that is hosted by firebase hosting has the "/__/auth/action" path with the correct code to handle all the auth actions.
    – nwarp
    Oct 1, 2021 at 5:45
  • This also works if you generate the emails with generateSignInWithEmailLink in Javascript and send the emails via your own email server. So even though I'm not using the templates (at all), changing the action url there did the trick. Also note that you need to change it in the firebase console. The google identity platform console doesn't have this possibility. Jul 29 at 23:44
5

You may refer to the "Customize the sender domain" section in the Firebase support article https://support.google.com/firebase/answer/7000714?hl=en

5

Say, your firebase link is https://myapp.firebaseapp.com/__/auth/action You want it https://auth.mydom.com/__/auth/action

  1. Create a CNAME in your domain(mydom.com) with the Name as auth and the Value as myapp.firebaseapp.com

  2. Then go to your Firebase Project -> Authentication -> Templates tab on top of the page -> click on pencil button -> customise action url on the bottom -> Replace https://myapp.firebaseapp.com/__/auth/action with https://auth.mydom.com/__/auth/action

  3. Now change the authDomain in the Firebase config json you use, in your frontend.

That's it.

3
  • The easiest if you have access to DNS records
    – DarkNeuron
    Nov 25, 2022 at 17:03
  • Would that redirect the user to the app once the link is clicked without a dynamic link?
    – Vilmir
    Mar 13 at 10:53
  • It will behave exactly the same as the previous link... so yes it will redirect. Mar 14 at 11:27
4

This is an issue I've had to scramble the internet to fix a good number of times now. This is unfortunately the case because there's no specific Firebase documentation for it.

Here are the steps to follow:

  1. Login to the firebase console, then go to the dashboard of the firebase project in question.
  2. Click the "Hosting" nav on the sidebar
  3. Click the "Get Started" button on the hosting page.
  4. A set up wizard will show up, but keep clicking "Next" without paying any mind to the instructions on the wizard
  5. When you're done clicking through, the actual "Hosting" page will show-up. Click the "Add custom domain" button.
  6. Follow through with the pop-up to add and verify your custom domain name.
  7. Once that is done, click the "Authentication" nav on the sidebar
  8. Click the "Templates" tab on the Authentication page.
  9. Now you can edit each email template by clicking the pencil button and then scroll down to click the "customise action url" button.
  10. Replace the domain name of the action URL with your custom domain (which you verified on step 6) and save it. Note, you are only replacing the domain name of the action URL. The path of the action URL should remain the same.

That's it you can now test that it's working by sending a "password reset" email or "account verification" email to yourself.

For a more detailed guide on the steps to follow, you can read this article that I wrote about it https://ifedapo.com/posts/customise-firebase-action-url.

It contains screenshots and more elaborate steps to follow so you might rather find it more helpful if the steps above seem too crammed up for you.

2
  • must the domain name end with .com since you're replacing it with firebaseapp.com or does it work with any other domain name with different endings? for instance replacing firebaseapp.com with myAppName.ng or with myAppName.de
    – Neldison
    Oct 17, 2022 at 22:15
  • 1
    Any domain should work, it doesn't have to end with .com. So yes, myAppName.ng should work just fine Oct 17, 2022 at 23:21
2

As of August 2022, the solution for this is to load the "Authentication" product of Firebase in the console ("Authentication" is under the "Build" product category on the left side or can be found in "All products"):

Authentication product in left navigation

Then select the "Templates" tab in the Authentication screen:

enter image description here

Select any of the Email templates (like "Password reset") and click on the Pencil icon to edit:

enter image description here

Click on the "Customize domain" link under the disabled domain name field: enter image description here

Add your custom domain name (which you already own and have DNS control over) in the dialog box that appears:

enter image description here

(If the "Continue" button is disabled after typing in the domain name, make sure you click outside of the text input box. The "Continue" button should then be active.)

The next dialog box will provide DNS records that need to be added/updated. There should be two TXT records (a v=SPF and a firebase record) and two CNAME records (two mail records). Update those on your DNS and then return to the Firebase Console to click on "Verify". Google may be able to see and verify the new records immediately or it may take some time (they claim up to 48 hours, but if it takes that long, it is possible a mistake was made).

0
0

If you utilize a DNS registrar that supports synthetic records ( e.g. Google Domains) you can do this simply with a synthetic record that supports SSL and path forwarding.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.