【发布时间】:2023-03-10 18:18:01
【问题描述】:
使用 Firebase 托管,当您部署应用时 you are asked 是否将所有 url 重写为 /index.html。这意味着 react-router 路由将被正确触发,无论它们是直接访问还是从主页导航到。
我们使用Create-react-app 和Create-react-app-buildpack 部署到Heroku。我们如何以相同的方式将所有 URL 重写为 /index.html?
在this issue之后,解释了routes指令,我在根目录中配置了一个static.json无济于事:
{
"routes": {
"/images/*": "/images/",
"/legal/*": "/images/",
"/media/*": "/media/",
"/fav/*": "/fav/",
"/styles/*": "/styles/",
"/**": "index.html"
}
}
【问题讨论】:
-
您可以使用像 serve 这样的实用程序来帮助您。 vijayt.com/post/deploying-react-app-heroku
-
你也可以通过
http-servergithub.com/http-party/http-server/pull/513/files使用这个hack
标签: reactjs heroku create-react-app buildpack