Почему сервер не отдает index.html?

<!DOCTYPE html>
<html lang="ru">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="Web site created using create-react-app"
    />
    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <title>React App</title>
  </head>
  <body>
    <script src='../src/index.js'></script>
    <div id="root"></div>
  </body>
</html>

const express = require('express');
const cors = require('cors');
const path = require('path');
const bodyParser = require('body-parser');
require('express-async-errors');
require('./connect-db');
const apiRouter = require('./api');

const app = express();

app.use(cors());

// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));

// parse application/json
app.use(bodyParser.json());

app.use('/api', apiRouter);

app.use((req, res) => {
  res
    .status(404)
    .sendFile(path.join(__dirname, '../../../public', 'index.html')) //отдает index.html, но без контента
});

app.use((err, req, res, next) => {
  res
    .status(500)
    .send({ error: err.message })
});


app.listen(3000, () => {
  console.log('Server is running on 3000 port')
});


Ответы (0 шт):