How to deploy static and dynamic files in firebase?

23 Views Asked by At

my file structure looks like this

-project-root
-functions // firebase functions
-public
 - Admin // dynamic contents
  - assets // folders like js css images
  - admin.html / sample file for admin login page
 - User // static contents
  - assets // folders like js css images
  - index.html / sample file for my static welcome page
- firebase.json

when i set up my firebase.json hosting into "public": "public/User", all my files under that folder works fine and i know that it would not deploy any files under Admin folder.

But when i set the hosting into: "public": "public", it cannot find my index.html under User folder. But when i change the url path extension with /Admin/admin.html, it reads my contents under that folder.

For reference this is my firebase.json file :

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/api/**",
        "function": "app"
      },
      {
        "source": "**",
        "destination": "/User/welcome.html"
      },
      {
        "source": "/Admin/**",
        "destination": "/Admin/admin.html"
      }   
    ],
    "cleanUrls": true,
    "trailingSlash": false, 
    "appAssociation": "AUTO",
    "headers": [
      {
        "source": "**/*.@(json)",
        "headers": [
          {
            "key": "Cache-Control",
            "value": "public, max-age=31536000, s-maxage=31536000"
          }
        ]
      }
    ]
  },
  "database": {
    "rules": "database.rules.json"
  },
  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ]
    }
  ],
  "storage": {
    "rules": "storage.rules"
  }
}

My index.html file under User folder has a href link connected to admin.html file under Admin folder

I checked all the path and it works fine in localhost.

Note that on my web project I only use public template.

0

There are 0 best solutions below