gpt4 book ai didi

javascript - 加载资源失败 : the server responded with a status of 404 (Not Found) in React. js 项目已部署

转载 作者:行者123 更新时间:2023-12-04 12:37:06 25 4
gpt4 key购买 nike

当我将我的 react 项目部署到 Surge 中时,构建成功并且可以获取应用 URL。
但是当我链接到 URL 时,我可以在检查控制台中看到一个空白页面和一些错误:

Failed to load resource: the server responded with a status of 404 (Not Found) 3.138a0231.chunk.css
Failed to load resource: the server responded with a status of 404 (Not Found) main.bd0d3f99.chunk.js:1
Failed to load resource: the server responded with a status of 404 (Not Found) main.bd0d3f99.chunk.css:1
Failed to load resource: the server responded with a status of 404 (Not Found)
Failed to load resource: the server responded with a status of 404 (Not Found)
Failed to load resource: the server responded with a status of 404 (Not Found) manifest.json:1
Manifest: Line: 1, column: 1, Syntax error. manifest.json:1
Failed to load resource: the server responded with a status of 404 (Not Found) 3.138a0231.chunk.css
Failed to load resource: the server responded with a status of 404 (Not Found) 3.138a0231.chunk.css
Failed to load resource: the server responded with a status of 404 (Not Found) main.bd0d3f99.chunk.css:1
这是我的 package.json 中的 react 启动脚本文件。
"scripts": {
"build": "REACT_APP_BACKEND=true PUBLIC_URL='/sing-app-react' node scripts/build.js",
"start": "node scripts/start.js",
"start:backend": "REACT_APP_BACKEND=true node scripts/start.js",
"test": "node scripts/test.js"
},
以及导致错误 https://lopsided-dinner.surge.sh/sing-app-react/static/css/3.138a0231.chunk.css 的 css 文件的链接地址

最佳答案

https://lopsided-dinner.surge.sh/sing-app-react/static/css/3.138a0231.chunk.css
这个由 react 脚本构建的网站 url 应该是 https://your domain/static/css...
删除构建脚本中的 PUBLIC_URL 并再次运行构建。

它将构建源引导到/static/....

希望这对你有意义!

关于javascript - 加载资源失败 : the server responded with a status of 404 (Not Found) in React. js 项目已部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60271280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com