![](/img/trans.png)
[英]Next.js Firebase Hosting 404 error on all except index.html
[英]Firebase: This file does not exist and there was no index.html found in the current directory or 404.html in the root directory
我在使用 firebase 部署我的網站時遇到問題。
我已經部署,但它一直顯示錯誤“此文件不存在,並且在當前目錄中找不到 index.html 或在根目錄中找到 404.html。”。
我檢查了目錄,但 index.html 文件位於公共文件夾中。
firebase.json,代碼如下
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
誰能指出問題是什么? 謝謝你。
使用 React 時,您部署的是構建(通常命名為“build”或“dist”)目錄,而不是“公共”目錄。 首先運行構建命令npm run build
然后它應該會生成我之前提到的目錄。
然后在您的firebase.json
中更新相同的內容:
{
"hosting": {
"public": "build", // <-- use that directory name here
....
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.