9

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?

2
  • 2
    We'll have HTML redirects implemented for hosting in the near future; the next month or two. I can't think of any way to do this without some server intermediary. Commented Jun 16, 2014 at 18:36
  • What is the status of this Kato? Commented Oct 25, 2015 at 23:57

1 Answer 1

16

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

Sign up to request clarification or add additional context in comments.

2 Comments

How does this relate to HTML5 mode and removing the #?
@JohnAndrews it means that all url's that don't match for an existing file, will be routed to index.html, where angular will pick them up and run the appropriate route for your application, if it exists. Basically he answered your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.