Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS HTML5Mode

I am using HTML5 mode in my angular app to turn off hashbangs and that is because I am going to be providing URLs for my users like:

http://myapp.com/nicklewis

Rather than:

http://myapp.com#/nicklewis

The latter works but it isn't ideal for vanity URLs.

So short of writing my own NodeJS app to resolve this issue, is there anything in Firebase I could make use of or not?

like image 228
Nick Lewis Avatar asked Jun 13 '14 13:06

Nick Lewis


1 Answers

Firebase just had a recent update that included this functionality. You can use it like so in your firebase.json:

"rewrites": [ {
    "source": "**",
    "destination": "/index.html"
} ]

This is the code sample used in their docs and will send any directory or file that is not found back to index.html.

It's important to note that you will need to update your firebase deployment tools to version 1.1.0 or higher for this to work:

$ npm update -g firebase-tools

You may need to use 'sudo' with this depending on your permissions.

You can read the documentation here: https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html

You can read about updating firebase tools here: https://www.firebase.com/docs/hosting/guide/command-line-tool.html

like image 124
jeff Avatar answered Oct 02 '22 12:10

jeff