Answer the question
In order to leave comments, you need to log in
How to set up react-route in conjunction with express?
I use React-Route and expess.
It is necessary to give the file public/index.html in all ways.
On the server, the code is as follows:
//устанавливаем папку public за статику.
app.use(express.static('public'));
//путь "/"
app.get('/', (req, res) => {
res.sendFile( __dirname + '/public/index.html' );
});
//путь "/signin"
app.get('/signin', (req, res) => {
res.sendFile( __dirname + '/public/index.html' );
});
<Router history={browserHistory}>
<Route path="/" component={Home} />
<Route path="/signin" component={LoginForm} />
</Router>
<Link to="/signin"> signin </Link>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question