Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase hosting URL needs .html to display a page

I am trying to host a website at Google Firebase. The index.html is shown as (e.x.)app.firebase.com, but when I want to access a page like login.html I need to type app.firebase.com/login.html, just app.fire-base.com/login doesn't work. How would I achieve this for every .html file in the directory (public), do I need to configure the firebase.json? I read the docs but I could not find any information.

Here is my .json

 {
      "hosting": {
        "public": "public",
        "signin": "/signin.html"

      }
    }
like image 462
Stavros Avramidis Avatar asked May 25 '17 06:05

Stavros Avramidis


People also ask

How do I change my firebase hosting URL?

Scroll down in 'Manage Site' and create a new site, then deploy there. You can't change your domain, but you can change the host! You can make as many sites as you want.

Can firebase hosting dynamic website?

Pair Cloud Functions with Firebase Hosting to generate and serve your dynamic content or build REST APIs as microservices. Cloud Functions for Firebase lets you automatically run backend code in response to HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment.


1 Answers

To omit the .html for all resource paths e.g. /login.html -> /login

  • add "cleanUrls": true to your .json.
  • firebase automatically redirects with a 301 code if user enters /login.html.

    "hosting": {
      // ...
    
      // Add the "cleanUrls" attribute within "hosting"
      "cleanUrls": true
    }
    

Read Control .html extensions to know more.


For specific routing: You can make a redirect/rewrite section in your .json as described in the following,

  • Configure redirects
  • Configure rewrites
like image 60
louisvno Avatar answered Oct 10 '22 15:10

louisvno