admin管理员组文章数量:1278789
When I deploy my react project into Surge, the build is successful and can get the app URL. But when I link to the URL, I can see one blank page and some bunch of errors in the inspect console:
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
Here is the react start script in my package.json
file.
"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"
},
And the link address to css file that causes the erros .138a0231.chunk.css
When I deploy my react project into Surge, the build is successful and can get the app URL. But when I link to the URL, I can see one blank page and some bunch of errors in the inspect console:
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
Here is the react start script in my package.json
file.
"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"
},
And the link address to css file that causes the erros https://lopsided-dinner.surge.sh/sing-app-react/static/css/3.138a0231.chunk.css
2 Answers
Reset to default 4https://lopsided-dinner.surge.sh/sing-app-react/static/css/3.138a0231.chunk.css
This website url built by react script should be something like https://your domain/static/css...
Remove the PUBLIC_URL in your build script and run build again.
It leads the build source to /static/....
Hopefully that makes sense to you!
In my case the issue was I was serving my react project from a build
folder and there was /build
in .gitignore
file. I removed /build
from .gitignore file and it worked
本文标签:
版权声明:本文标题:javascript - Failed to load resource: the server responded with a status of 404 (Not Found) in React.js Project deployed - Stack 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741260823a2367587.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论