3 回答

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超7個贊
將 URL 重寫為 index.html 時應(yīng)選擇“N”。
所以,我建議你重做firebase初始化。

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超8個贊
您需要設(shè)置PUBLIC_URL
webpack 構(gòu)建包所需的環(huán)境變量。
在生成的 html 中,文件中不應(yīng)包含%PUBLIC_URL%
字符串,build /index.html
例如:<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
,它應(yīng)該有完整的 url,例如:<link rel="icon" href="https://<your-app-name>.firebaseapp.com/favicon.ico" />
要解決這個問題:
GitHub部分:
轉(zhuǎn)到 Githup 中的存儲庫,然后單擊 repo
settings
。在存儲庫設(shè)置側(cè)欄上,展開
Secrets and variables
菜單項(xiàng),然后單擊actions
。在頁面上
Actions secrets and variables
,單擊Variables
選項(xiàng)卡,然后單擊New repository variable
。在頁面上
Actions variables / New variable
填寫,然后單擊。Name
PUBLIC_URL
Value
https://<your-app-name>.firebaseapp.com
Add variable
回購代碼部分:
打開
.github/workflows/firebase-hosting-merge.yml
并添加
env: PUBLIC_URL: ${{ vars.PUBLIC_URL }}
上面的name: Deploy to Firebase Hosting on merge
線。
提交更改并推送。
注意:確保將 firebase 托管公共目錄設(shè)置為文件build
中firebase.json
。
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
添加回答
舉報(bào)