簡體   English   中英

Firebase 托管 static 網站無法正常工作

[英]Firebase hosting static website not working

我正在嘗試在 firebase 上托管 static 網站。 (使用 macOS Catalina)我用 npm 安裝了 firebase CLI。 我網站的目錄名為 Knight 登錄后,我運行以下命令:

firebase init

然后我選擇了以下內容:您要為此文件夾設置哪些 Firebase CLI 功能?

hosting

你想用什么作為你的公共目錄?

public (I also tried dist and knight and Knight and KNIGHT)

配置為單頁應用(將所有 url 重寫為 /index.html)?

Y ( I also tried No )

文件 public/index.html 已經存在。 覆蓋?

N

然后初始化過程就完成了。 當我嘗試firebase serve並到達 http://localhost:5000 時,我得到了 firebase 歡迎頁面。 在此處輸入圖像描述

如何查看我的網站? 我做錯什么了嗎?

我注意到 firebase 在我調用 firebase init 后沒有在我的目錄中寫入任何文件。 在此處輸入圖像描述

Firebase CLI 使用的過程非常簡單:

  1. 您在特定目錄中運行firebase init
  2. 回答“您想將什么用作公共目錄?” 與您的index.html和其他 web 文件相對於您運行firebase.init的目錄的路徑的問題

既然你說你在Knight有你的 web 站點,你應該回答“你想用什么作為你的公共目錄?” Knight


更新:您似乎在index.html文件所在的同一目錄中運行firebase init命令。 在這種情況下,您的“公共方向”是. ,因為它與項目所在的目錄相同。

好的,我發現了問題。 After searching for firebase.json on my machine I realized that firebase was writing the files in my user directory, instead of writing them where I called firebase init. 所以我的index.html路徑看起來像:

/Users/DCI/Documents/Knight/index.html

但是 firebase 正在將文件寫入:

/Users/DCI

所以我要做的就是將Documents/Knight作為 firebase init 的公共目錄。 完成此操作后,我調用了 firebase 服務和 firebase 部署,它運行良好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM