Open Tegos opened 6 years ago
@Tegos I resolved it this way:
1) we change the route for all the statics like this:
app.use ('/static', express.static ('./server/static/'));
app.use ('/static', express.static ('./client/dist/'));
2) then we add another route that allows for access of index.html from ANY route.
app.use ('/*', express.static ('./server/static/'));
3) Because in ExpressJS the ORDER of specified routes MATTERS we need to take the line from step 2 and put it below any other routes (So as not to silence them, expressjs will take first matching route and use it).
...
app.use ('/api', apiRoutes);
app.use ('/*', express.static ('./server/static/')); // Paste this line after the one above
4) And finally change paths for resources in index.html.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hey there!</title>
<link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
<div id="react-app"></div>
<script src="/static/js/app.js"></script>
</body>
</html>
5) Done, try accessing /dashboard directly.
happy coding!
@zhabinsky thanks!
After login, if reload page Dashboard on enter manually http://localhost:3000/dashboard the page does not work.