score:1
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} />
Source: stackoverflow.com
Related Query
- React Single Page app with browserHistory possible?
- Serving a static html page from a single page react app with react router
- Adding underline to current page section in single page react app with Chakra.ui
- structure of a Backbone and React single page app
- Is it possible to export React single page website as HTML?
- How to implement the OAuth2 Authorization code grant with PKCE for a React single page application?
- Navigation in a single page app with react.js
- react-router throwing 404 upon page refresh with React app hosted on GoDaddy
- Enable single page app react hot reload webpack
- React app showing page with "404 the requested path could not be found" when using Apache
- Is it Possible to redirect to installed flutter app page from react app when open in mobile browser
- Symfony 4 how to setup SPA ( single page app ) with React?
- Single page app with REST API architecture
- Keeping Google login persistent on reloading single page react app
- Embed a single react component created with create-react-library into html page
- React Where to place login page for a one page app with a side menu
- React app not loading js file when accessing it with a non home page url
- How can I show single data per page in react with javascript data file?
- React Route does not work - Single page app
- Blank page after deployment - React app with node
- Is it possible to place simple app with React and MobX within one html page?
- Handling form with single state in React for web app
- Create react app served with nginx and oauth gives me refresh page issue
- React app rendering empty page with no error from the console
- Unable to make api calls from React Single Page app
- How do I install a React app based on react-router's browserHistory into a WordPress page on Apache?
- React single landing page with components
- React - Wrapping all components in redux provider with store injection, Multi page app
- I Have A Problem With Deploying My React App In Github Pages, It Shows Me A Blank Page
- Next.js / React single page app needs urls for each item
More Query from same tag
- Handle new Redux for a global search filter
- Chakra UI using multiple models in a single component
- Keep having the error "TypeError: Cannot read property 'map' of undefined" when using map function in React js
- Could not type any character in TextField with name="lenghts.byDay"?
- react component not rendering on my view
- How to remove HTML div on click using Javascript
- How can I serve a React app from our server?
- undefined value in a component method
- Material-ui adding Link to Radio Button component from react-router
- How to convert TypeScript to JavaScript in React JS
- Passing object to component
- Can I use the "?." syntax in react?
- Changing state based off result of helper function in component
- Display drop down values upto the width of drop down box using css
- How to write Styled Components for conditional renders with on Click event?
- Setting the fontSize of <html> in React for using REM in responsive design
- How to achieve minimum character length feature in react material-ui's autocomplete
- Multi file upload in react
- Is there a way to override style from Semantic-UI with style from Styled-Components in ReactJS?
- How do you add redirect after QR code scan
- Trying to get header over the first element with the value of specific date
- Using setState (Class components) as a beginner React developer
- React.js document.querySelectorAll() not returning anything
- Reactjs insert specific row to top of table
- How to add multiple pages in grapesjs?
- Why does simply fetch data cause React Component to rerender
- webpack bundle.js not found - 404 error
- Testing nested functions that call Promises in Jest
- how to call a child component from parent component in electron-es6-react
- How to setup open each external link in new tab?