部署时,heroku告诉我我的构建成功,但是我得到Failed to load resource: the server responded with a status of 400 (Bad Request)了favicon和manifest,以及Manifest: Line: 1, column: 1, Unexpected token.Lighthouse告诉我它根本没有链接到manifest.json。我不确定这些是否相关,如果是这种情况,我将提出一个新问题。我在节点服务器上使用Reactjs。
这是我的server.js
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
const app = express();
const PORT = process.env.PORT || 3001;
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
if (process.env.NODE_ENV === "production") {
app.use(express.static("client/build"));
}
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "./client/public/index.html"));
});
app.listen(PORT, function() {
console.log(` ==> API Server now listening on PORT ${PORT}!`);
}); …Run Code Online (Sandbox Code Playgroud)