Adr*_*rdo 5 javascript node.js express reactjs manifest.json
您好,我将一个 react/express 项目推送到 heroku ( https://polar-oasis-57801.herokuapp.com/ ) 并在控制台中收到以下错误: Chrome 控制台错误消息
我尝试查找此错误,似乎我需要更改 manifest.json 文件中的某些内容,但我不确定。任何建议都会有所帮助。这是我的清单文件:
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
Run Code Online (Sandbox Code Playgroud)
还有我在 Github 上的项目:https : //github.com/bernar83/cat-cards
gba*_*zzi 10
此错误意味着对 的请求manifest.json未返回有效的 JSON 响应。考虑到它由于开始而失败的事实,它可能返回一个 HTML <。
确保manifest.json正确链接并确保在部署过程中保持其完整性。尝试导航到http://yoururl/manifest.json并检查结果。
EDIT1:您的清单链接似乎已损坏。在https://github.com/bernar83/cat-cards/blob/master/client/public/index.html 中,尝试替换
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
Run Code Online (Sandbox Code Playgroud)
和
<link rel="manifest" href="manifest.json" />
Run Code Online (Sandbox Code Playgroud)
EDIT2:刚刚检查了您的 Heroku 链接并可以确认错误。您的页面试图manifest.json在/cat-cards/manifest.json错误的路径下找到。它应该只是manifest.json
我在我的 server.js 文件中添加了此更改,"/cat-cards/"所以现在它是app.use("/cat-cards/", express.static("client/build"));. 添加该更改并推送到 Heroku 使我的网站正常运行。这对我有帮助:https ://github.com/facebook/create-react-app/issues/1812#issuecomment-286511320