I am serving React build directly. So please consider it for your answer.
import express from "express";
let port = process.env.PORT || 8000;
const app = express();
app.use(cors());
app.use(express.json());
...
// // All start from index.html
app.get("/*", (req, res) => {
res.sendFile(path.resolve("index.html"));
});
app.listen(port, () => {
console.log("server is online: " + port);
});