Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase rewrite based on subdomain

I've got a project hosted on firebase. I'd like to use a domain and subdomain as follows:

example.com: rewrite to index-landing.html
app.example.com: rewrite to index.html

Is that possible? I've tried the following under the hosting section of firebase.json:

"rewrites": [
  {
    "source": "https://example.com",
    "destination": "/index-landing.html"
  },
  {
    "source": "https://app.example.com/**",
    "destination": "/index.html"
  }
]

Any ideas?

like image 252
jloosli Avatar asked May 03 '17 18:05

jloosli


People also ask

How do I add a custom domain to my Firebase project?

Make sure that you've completed the "Get Started" wizard from your project's Firebase Hosting pageso that you have a Firebase Hosting site in your Firebase project. Step 1: Add domain From your project's Hosting page, enter the wizard for connecting a custom domain: If you have only one Hosting site, click Connect domain.

Why do I need to re-verify my domain ownership in Firebase?

Needs Re-Verification Firebase may require you to manually re-verify your domain ownership if any of the following situations happen: The TXT record added when you initially verified your domain ownershipwas altered or removed from your domain's DNS settings.

What is rewrite rule in Firebase Hosting?

Firebase Hosting only applies a rewrite rule if a file or directory does not exist at a URL path that matches the specified source or regex URL pattern. When a request triggers a rewrite rule, the browser returns the actual content of the specified destination file instead of an HTTP redirect.

How do I connect my apex domain to Firebase?

If requested in the Connect Domainsetup wizard, verify your apex domain. These steps ensure that your domain is not already linked with a Firebase project and that you own the specified domain. In your domain provider's site, locate the DNS management page. Add and save a new record with the following inputs: Type: Add a TXT record.


2 Answers

As far as I can tell, this is now possible. I found this really good article/video while trying to find a solution: https://fireship.io/lessons/deploy-multiple-sites-to-firebase-hosting/

like image 191
hendrikswan Avatar answered Sep 20 '22 14:09

hendrikswan


I have the same issue. I think rewrites only support directories not subdomains. The simple solution is to just create two different Firebase projects.

like image 21
Matt Kaufman Avatar answered Sep 17 '22 14:09

Matt Kaufman