在 Heroku 上配置单页 Create-React-App
Configuring a single page Create-React-App on Heroku
使用 Firebase 托管,当您部署应用程序时 whether to rewrite all urls to /index.html. This means react-router 路由将被正确触发,无论它们是直接访问还是从主页导航到。
我们使用 Create-react-app and Create-react-app-buildpack 部署到 Heroku。我们如何以相同的方式将所有 URL 重写为 /index.html?
按照this issue, explaining about the routes 指令,我在根目录中配置了一个static.json 无济于事:
{
"routes": {
"/images/*": "/images/",
"/legal/*": "/images/",
"/media/*": "/media/",
"/fav/*": "/fav/",
"/styles/*": "/styles/",
"/**": "index.html"
}
}
在项目根目录下创建一个static.json
文件,内容如下:
{
"root": "build/",
"routes": {
"/**": "index.html"
}
}
更多here.
使用 Firebase 托管,当您部署应用程序时
我们使用 Create-react-app and Create-react-app-buildpack 部署到 Heroku。我们如何以相同的方式将所有 URL 重写为 /index.html?
按照this issue, explaining about the routes 指令,我在根目录中配置了一个static.json 无济于事:
{
"routes": {
"/images/*": "/images/",
"/legal/*": "/images/",
"/media/*": "/media/",
"/fav/*": "/fav/",
"/styles/*": "/styles/",
"/**": "index.html"
}
}
在项目根目录下创建一个static.json
文件,内容如下:
{
"root": "build/",
"routes": {
"/**": "index.html"
}
}
更多here.