we use react-roucter-dom
with http-server
, when user loads main page and click navigation links , new pages will loaded perfectly , but when user refresh page in that route , it returns 404 .
It means HTML5 pushState
is not working with http-server
.
example :
<Router>
<Route exact path="/" component={Home} />
<Route path="/about" component={About} />
<Route path="/topics" component={Topics} />
</Router>
If user go to /about
page and refresh it , 404 error will happen
Is there a way to fix this issue ?
homepage
inpackage.json
or set the.env
variable accordingly:PUBLIC_URL=http://localhost:8080 yarn build && http-server --proxy http://localhost:8080? ./build
– Wisp