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?

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

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:46