Home>
There is a server on express and in its root directory there is a static folder, it contains several application reactants, something like this:
app:
static:
react1
react2
I'm trying to make sure that when I contact /react1 and /react2 , the express will display the required application.
app.js:
app.use (express.static (path.join (__ dirname, "static")));
app.use ("/", indexRouter);
index.router:
router.get ('/react1', (req, res)= >
{
res.sendFile (path.join (__ dirname, '..', 'static', 'react1', 'index.html'))
});
router.get ('/react2', (req, res)= >
{
res.sendFile (path.join (__ dirname, '..', 'static', 'react2', 'index.html'))
});
When I try to navigate through these handles, I get a blank page. What am I doing wrong?
The html page with the 'root' div is loaded, in which everything should be rendered, but this does not happen. It is important for me to do this on the express train, since these are private pages, before rendering of which you need to log in
Salavat2021-12-22 21:08:46Related questions
- javascript : What's the problem with importing a package?
- javascript : Why do I get a jsx file instead of js after building a project with webpack using babel
- javascript : The simplest code on React.js does not work
- javascript : JS: wrap links found inside a string in an element
- javascript : A value different from the displayed value is UPDATEd to MySQL.
- javascript : I want to UPDATE using placeholders in Node + MySQL
- javascript : How to query data with PostgreSQL in reverse order
- javascript : Problem with Route
- javascript : Running webPack 5 in development mode does not see html page
- javascript : React. Send a get request to the server when pressing Enter
You can distribute statics in the form of React applications without a node with an express, using only Nginx, for example. And what does a blank page mean? index.html is served? Do statics queries work?
Anatoly2021-12-22 20:05:32