[英]Firebase serve doesn't include other pages in React
我有一個使用 React-Router 的 React 應用程序,在index.js
中有以下內容:
render(
<Router>
<Switch>
<Route exact path="/">
<Main />
</Route>
<Route path="/privacy">
<Privacy />
</Route>
</Switch>
</Router>,
document.getElementById("root")
);
在執行yarn build
然后serve -s build
時,我可以訪問 localhost:5000/privacy 並查看隱私頁面,但是當我執行firebase serve
時,同樣的 URL 會給出 404。
我的 firebase 托管配置也設置為 build/ 文件夾,因此它們都應該從同一個文件夾中讀取。 我還可以看到/
路徑的其他更新很好,只是其他鏈接不起作用。
所以我的問題是:為什么firebase serve
不包括其他頁面?
所以我似乎已經解決了我的問題。 這是我采取的步驟:
firebase init
build
作為我的公共目錄 之后,我運行firebase serve
,可以在正確的 URL 看到我的其他頁面。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.