S
S
symblight2017-03-15 17:14:31
Node.js
symblight, 2017-03-15 17:14:31

How to solve react-router page reload problem?

The links are successfully followed, but it's worth reloading the page or going directly to the link, as it comes 404
I use react-router-dom
And on the server I address it this way:
app.js

Import api from './api.js'

app.use(webpackDevMiddleware(compiler,{
    stats:{
        historyApiFallback: true,
        colors:true
    }
}));
app.use(webpackHotMiddleware(compiler));
app.use('/',api);
app.use('/*', express.static(__dirname+ '/'));

const server = app.listen(8080,()=>{
    console.log(`server up ${config.serverPort}`)
})

api.js - Requests are stored.
How to set up Router?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SergeyBugai, 2017-03-15
@symblight

I think that the problem is in
what form do you have addresses in the browser, through /#/ or just / ?

M
Maxim, 2017-03-15
@maxfarseer

I answered somewhere on the toaster, I can’t find the question, but the answer lies here in the chapter if your bundle is not loading, but most likely it is.
If not, show the error in the browser console.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question