【发布时间】:2021-02-21 14:53:41
【问题描述】:
我在 Heroku 上看到一个问题,我在本地没有遇到问题。我看过各种文章和其他解决此问题的 SO 帖子,我了解到这与在我的应用程序中正确配置 static.json 文件有关,以便 heroku 正确处理前端反应路由,但我在解决这个问题时遇到了一些真正的麻烦。
-
我正在使用以下构建包,并确认它们是通过 Heroku 仪表板 > 设置安装的:
-
https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku-community/static.tgz -
https://github.com/mars/create-react-app-buildpack -
使用
gin-gonic服务器并提供./web服务于我的.Dockerfile指定的前端 -
我有以下 static.json:
{
"root": "build/",
"routes": {
"/**": "index.html"
},
"clean_urls": false,
"https_only": true,
"headers": {
"/**": {
"Strict-Transport-Security": "max-age=31557600"
}
}
}
- 我的项目结构如下:
/app
- /main.go
- /server
-- /server package .go files...
- /client
-- /public
-- /src
-- /remaining react related files and assets...
我尝试在应用程序根目录和client 目录中添加static.json 文件,但均无济于事。如果我刷新或从外部网站导航到主页以外的任何内容,仍然会看到 404。
【问题讨论】:
标签: reactjs go heroku react-router