我创建了一个反应应用程序,它在本地运行良好。为了将其部署在 firebase 中,我使用了
firebase init
并按照步骤 npm run build
和 firebase deploy
进行操作。现在我在部署的应用程序的主页上收到此错误。
找不到页面 该文件不存在,当前目录下未找到index.html,根目录下未找到404.html。为什么我会看到这个? 您可能为您的应用程序部署了错误的目录。检查 firebase.json 并确保 public 目录指向包含 index.html 文件的目录。 您还可以在网站的根目录中添加 404.html,以用自定义错误页面替换此页面。
这是
firebase.json
文件的代码。
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
我的构建文件夹路径位于根目录中,如下所示:
我也遇到过同样的问题,但现在它对我有用。
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [{
"source": "**",
"destination": "/index.html"
}]
}
}
Cmd执行顺序:
这是我最近使用 Firebase 托管的经验,我描述了我遇到的问题以及如何解决它们。也许有人会发现它们很有用。请阅读帖子的评论部分以遵循解决方案,谢谢。 https://x.com/Sanji_vals/status/1773488210519171100?s=20