當我在本地主機上運行程式時,我可以使用 url 瀏覽我的程式,但當它托管在 firebase 上時則不行。
例如)鍵入“www.localhost:4200/home”帶我回家。
鍵入“www.localhost:4200/contact”將我帶到聯系頁面。
但
當我在firebase上托管網站時,我只能直接訪問它:“ www.portfoliotest.web.app ”并且通過按鈕進行路由作業,但當我輸入“www.portfoliotest.web.app/home”或“www”時不能.portfoliotest.web.app/contact”,但我收到“找不到頁面”firebase 錯誤。
如何設定路由以便我可以通過 url 訪問我的頁面?
謝謝你。
uj5u.com熱心網友回復:
您的路由不是您的問題:這是您設定 Firebase 的方式。
在您的firebase.json中,您需要將所有 URL 重定向到index.html:
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
這樣,您的 Angular 路由優先于靜態檔案服務。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/447484.html
