1

So I have an angular 5 application deployed under firebase hosting with domain www.mydomain.com. Now I have one more angular 5 application connecting to the same project and I would be treating this as admin panel and would like to deploy under a subdomain - www.admin.mydomain.com

I have properly configured my TXT records for respective domains and when I hit both the URLs it is going to display first project contents.

My firebase.json for the first application is as follow:

{
    "hosting": {
        "public": "dist",
        "ignore": [
            "firebase.json",
            "**/.*",
            "**/node_modules/**"
        ],
        "rewrites": [{
                "source": "**", //for any route request
                "destination": "/index.html"
            },
            {
                "source": "https://admin.mydomain.com/**", //specific to this request
                "destination": "/admin/index.html"
            }
        ]
    }
}

The second application's build output directory will be within the first application's dist directory and both the projects are in same level in my system.

second app's angular-cli.json contains "outDir": "../firstapp/dist/admin",

So once both are built and place within dist directory of the first project's application and I've successfully deployed the same.

But still, when I browse 2 different URLs it always serves pages from the first application and admin directory under dist folder is never considered.

The built version of the project has below structure

-dist
   -admin
       -index.html
       -inline.370847efdcd50e26c23c.bundle.js
       -main.ff340c7513400e78d233.bundle.js
       -polyfills.32225f5d64cec6731cb0.bundle.js
       -styles.d41d8cd98f00b204e980.bundle.css

   -index.html
   -inline.09d20b30b3c5121cfc56.bundle.js
   -main.c97b32660a6d046955c8.bundle.js
   -polyfills.1364aed46b3c77673c40.bundle.js
   -styles.2926c591943e8077f48a.bundle.css

I am under the impression that below rewrite entry will make sure to serve contents from admin directory under dist directory for all the requests from admin.mydomain.com.

"source": "https://admin.mydomain.com/**", //specific to this request
"destination": "/admin/index.html"

Could someone please clarify what am presuming or doing wrong here and how I can achieve this?

Guruprasad J Rao
  • 29,410
  • 14
  • 101
  • 200
  • 2
    A single Firebase Hosting project can only host a single web site. While the site can be tied to different (sub)domains, each of those will be serving the exact same content. There is no way to tie different (sub)domains to different sets (e.g. directories) of content. See https://stackoverflow.com/questions/43581735/firebase-hosting-with-multiple-directories-at-multiple-domains and https://stackoverflow.com/a/30174354 – Frank van Puffelen Mar 18 '18 at 14:42
  • @FrankvanPuffelen Sad Sir. Anywhere in near future the support for this is provided? – Guruprasad J Rao Mar 18 '18 at 14:49
  • Have you tried switching the rewrite rules? So that the ** pattern is the last rule. – Korbinian Kuhn Mar 18 '18 at 14:49
  • @KorbinianKuhn Let me try it once though.. – Guruprasad J Rao Mar 18 '18 at 14:56
  • @KorbinianKuhn No use bro.. Doesn't work at all.. – Guruprasad J Rao Mar 18 '18 at 15:18

0 Answers0