【发布时间】:2019-05-10 20:37:28
【问题描述】:
部署时,heroku 告诉我构建成功,但我得到了 Failed to load resource: the server responded with a status of 400 (Bad Request) 的图标和清单以及 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}!`);
});
这是我的 index.html 的头部
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,
shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<title>React App</title>
</head>
如果您需要更多信息,如果这是重复问题,或者这些问题是否无关,请告诉我,以便我采取相应措施。
【问题讨论】:
标签: javascript reactjs heroku