我在前端使用React.js 。代码以完美的流程运行,在使用流程时没有显示错误。
但是 NETWORK 选项卡在生产模式下显示页面的 404 错误。但它在网络选项卡中使用代码 200 的本地服务器上工作正常。
这影响了网站的优化,并且由于页面上持续存在 404 错误,谷歌广告无法运行。
注意:该错误显示在除主页之外的所有页面上。
生产和本地网络选项卡的屏幕截图分别如下。
当单击具有 404 错误的文件时,它会向我显示我的 react 应用程序的 index.html 中的代码,在 <!Doctype html> 前面有一个红叉
说
[显示 404 错误的 index.html 文件的控制台日志屏幕截图]
package.json 中的脚本
{
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"scss": "node-sass --include-path ./src --include-path ./node_modules src/ -o src/",
"sitemap": "babel-node src/sitemap/generator.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"babel-register": "^6.26.0",
"redux-devtools": "^3.5.0"
}
}