gpt4 book ai didi

reactjs - 在 Heroku 上配置单页面 Create-React-App

转载 作者:行者123 更新时间:2023-12-03 13:44:11 24 4
gpt4 key购买 nike

使用 Firebase 托管,当您部署应用时 you are asked是否将所有 url 重写为/index.html。这意味着react-router无论是直接访问还是从主页导航到,路由都会被正确触发。

我们使用Create-react-appCreate-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"
}
}

最佳答案

在项目根目录中创建一个 static.json 文件,其中包含以下内容:

{
"root": "build/",
"routes": {
"/**": "index.html"
}
}

更多 here .

关于reactjs - 在 Heroku 上配置单页面 Create-React-App,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48503348/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com