0
0
FirebaseHow-ToBeginner Ā· 4 min read

How to Set Up SSL on Firebase Hosting Quickly

Firebase Hosting automatically provisions and renews SSL certificates for your custom domains when you add them using the Firebase Console or the Firebase CLI. Simply connect your domain to Firebase Hosting, and SSL is set up without extra configuration.
šŸ“

Syntax

To set up SSL on Firebase Hosting, you mainly use the Firebase CLI commands and the Firebase Console. The key steps are:

  • firebase hosting:sites:create <site-name> - Create a hosting site (optional for multi-site projects).
  • firebase hosting:add - Add a custom domain to your Firebase Hosting site.
  • Verify domain ownership via DNS records as instructed.
  • Firebase automatically provisions SSL certificates for your domain.

No manual SSL certificate upload is needed because Firebase manages it for you.

bash
firebase hosting:add
# Follow prompts to add your custom domain
# Verify domain ownership by adding DNS TXT records
# Firebase provisions SSL automatically
šŸ’»

Example

This example shows how to add a custom domain and enable SSL on Firebase Hosting using the CLI:

bash
firebase login
firebase init hosting
firebase deploy
firebase hosting:add
# Enter your custom domain when prompted
# Follow instructions to add DNS TXT record for verification
# Wait for Firebase to provision SSL certificate automatically
Output
āœ” Success! Your domain is verified. āœ” SSL certificate provisioning started. āœ” Your site is now available at https://your-custom-domain.com
āš ļø

Common Pitfalls

Common mistakes when setting up SSL on Firebase Hosting include:

  • Not verifying domain ownership by adding the required DNS TXT record, which blocks SSL provisioning.
  • Using incorrect DNS records for domain verification or pointing the domain to the wrong Firebase Hosting target.
  • Expecting immediate SSL availability; it can take up to 24 hours for SSL certificates to be issued.
  • Trying to upload SSL certificates manually, which Firebase does not support.
bash
## Wrong: Trying to upload SSL cert manually (not supported)
# No CLI command exists for manual SSL upload

## Right: Use firebase hosting:add and verify domain
firebase hosting:add
# Follow prompts and DNS verification
# Firebase manages SSL automatically
šŸ“Š

Quick Reference

StepCommand/ActionNotes
1firebase loginLog in to your Firebase account
2firebase init hostingInitialize hosting in your project
3firebase deployDeploy your site to Firebase Hosting
4firebase hosting:addAdd your custom domain
5Add DNS TXT recordVerify domain ownership via DNS
6Wait for SSLFirebase provisions SSL automatically
7Access siteUse https://your-custom-domain.com
āœ…

Key Takeaways

Firebase Hosting automatically provisions SSL certificates for custom domains.
Add your custom domain with 'firebase hosting:add' and verify ownership via DNS.
No manual SSL certificate upload is needed or supported.
SSL provisioning can take up to 24 hours after domain verification.
Always verify domain ownership correctly to enable SSL on your site.