Search code examples
firebasesubdomainhostingfirebase-hostingmulti-project

Firebase subdomain wildcard to one or more project(s)


We are writing a project for schools. We need different subdomains to any school and users should be different. Any email can be registered on different subdomains as other user.

So we want to connect our domain and all subdomains to a project with *.example.com wildcard. We will read subdomains as values. I think we can manage it with the structure below.

Example 1;

     requestUrl           |       firebaseProject                 |       displayUrl
https://example.com      ==> https://projectMain.firebaseapp.com ==> https://example.com
https://sub1.example.com ==> https://projectSub1.firebaseapp.com ==> https://sub1.example.com
https://sub2.example.com ==> https://projectSub2.firebaseapp.com ==> https://sub2.example.com

/// OR

Example 2;

     requestUrl           |       firebaseProject             |       displayUrl
https://example.com      ==> https://project.firebaseapp.com ==> https://example.com
https://sub1.example.com ==> https://project.firebaseapp.com ==> https://sub1.example.com
https://sub2.example.com ==> https://project.firebaseapp.com ==> https://sub2.example.com

Is that posible or not?


Solution

  • Unfortunately, this is not supported by Firebase Hosting. There can only be a single canonical domain for a Hosting site, and any other subdomain will be redirected to the canonical domain.