![](/img/trans.png)
[英]JS/AJAX 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) in React.js Project deployed
當我將我的反應項目部署到 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
文件中的反應啟動腳本。
"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"
},
以及導致錯誤的 css 文件的鏈接地址https://lopsided-dinner.surge.sh/sing-app-react/static/css/3.138a0231.chunk.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/....
希望這對你有意義!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.