部署angular 6应用程序后,Firebase托管显示欢迎页面?

eimct9ow  于 2022-11-25  发布在  Angular
关注(0)|答案(9)|浏览(126)

我想开发的Angular 6应用程序,但部署后,firebase只显示欢迎页面。
以下是我采取的部署步骤。
1.已安装的firebase工具

  1. ng build --prod(在我的应用程序中)
    1.火线初始化
    1.是否准备继续?(Y/n)y
    1.(*)托管:配置和部署Firebase托管站点
    1.您要使用哪一个做为公用目录?(public)dist
    1.是否配置为单页应用程序(将所有URL重写为/index.html)?(y/N)y
    1.文件dist/index.html已存在。是否覆盖?(y/N)y
  2. Firebase初始化完成!
    1.在此步骤中,我删除了dist文件夹并再次运行ng build --prod
    1.在dist目录内的子文件夹中的Angular 构建应用程序,因此我将包含index.html的子目录中的所有内容复制到dist/
    1.火力基地部署
  3. firebase开放式主机:站点
    但在做了所有这些之后,我仍然在链接中得到欢迎页面。
    我到底做错了什么!
dced5bon

dced5bon1#

尝试:8.文件dist/index.html已经存在。覆盖?(y/N)N并以匿名模式打开应用程序的链接。说真的,我被困了几个小时,因为这个firebase索引被缓存在我的案例中,所以这就是为什么我在部署后看不到我的应用程序的原因。

gudnpqoy

gudnpqoy2#

浏览器缓存也是我的问题。如上所述,尝试隐姓埋名或使用proxysite.com(非常有用的网站)来避免浏览器缓存

anhgbhbe

anhgbhbe3#

在我的例子中,我是在项目目录(src)中初始化firebase的。只要检查一下你所在的目录,它应该在顶层。
在你构建它并尝试部署它之后,它将是相同的,因为网页已经被缓存了。

2mbi3lxu

2mbi3lxu4#

**问题是:**firebase正在查找index.html文件,有时它并不直接存在于dist目录中
**解决方案:**将firebase.json中的public路径更新为"public":"dist/ProjectName"dist文件夹中index.html文件的路径
示例

{
  "hosting": {
    "public": "dist/<YourProjectName>",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/dist/index.html"
      }
    ]
  }
}
yhived7q

yhived7q5#

这对我很有效:

  • 删除.firebase文件夹
  • 删除.firebaserc
  • 删除firebase.json

现在运行如下:

$ firebase init hosting
? File build/web/index.html already exists. Overwrite? No
$ firebase deploy --only hosting
cu6pst1q

cu6pst1q6#

检查终端上的路径。如果问题仍然存在,则删除firebase自动创建的文件夹并部署项目

ncecgwcz

ncecgwcz7#

配置为单页应用程序(将所有URL重写为/index.html)?否?使用GitHub设置自动构建和部署?否

  • 是否写入public/404.html?文件public/index.html已存在。是否覆盖?否

此错误是由您的网站文件夹的公共文件夹内的index.html生成的。

whlutmcx

whlutmcx8#

文件build/index.html已经存在。是否覆盖?没有npm运行build firebase deploy --仅托管

14ifxucb

14ifxucb9#

在我的例子中,我不得不在firebase.json中将public更改为dist,这样在我将Firebase函数添加到我的项目后,它就指向了我的dist文件夹(而不是包含保留页面的公共文件夹):

"hosting": {
   "public": "dist",
   ...
}

相关问题