score:1

Accepted answer

in order to use the browser history, you will need a backend that can handle routing for all of your possible routes. if you do not plan on having a backend that can support routing (e.g., you will be serving static files) you should stick to the hash history.

the basic explanation of how browser history works is that it looks at the pathname of the current url and attempts to match that against the known routes. in your included error, your pathname is /users/mike/project/index.html. that means that in order for react router to match that url, you would have to have defined the <route>'s path (or have a series of nested <route>s) to be /users/mike/project/index.html.

<route path='users/mike/project/index.html' component={app} />

the hash history works with static files because it just appends a hash symbol after the pathname and determines the route by what falls after that.

if your issue is just that you do not like having the query key (the ?_k=jkadjlkd), you can specify that that should not be included when you create your history instance. the urls will still include the #, but no longer have the key "junk" attached to them.

import { router, userouterhistory } from 'react-router'
import { createhashhistory } from 'history'

const apphistory = userouterhistory(createhashhistory)({ querykey: false })
<router history={apphistory} />

Related Query

More Query from same tag