Reputation: 195
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
Upvotes: 6
Views: 33606
Reputation: 748
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
Upvotes: 0
Reputation: 122
https://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!
Upvotes: 4