Remove Hash Mode on Netlify (VueJS)

The Brown BoxThe Brown Box
1 min read

Sometimes our FE framework make the default history mode is hash mode.
So the url gonna look like this: https://domain.com/#/path
It looks unnatural and also make us confuse when navigating.

To remove this:

  1. In the code
  • Do not use createWebHashHistory

  • Use createWebHistory instead

  1. In the root directory
  • create new file name: netlify.toml

  • content is below, this is to make sure our spa app is handling the routing, not the webserver

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200
0
Subscribe to my newsletter

Read articles from The Brown Box directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

The Brown Box
The Brown Box