Heroku build "failed to compile" 因为 gitignore

Heroku build "failed to compile" because of gitignore

我正在尝试将使用“create-react-app”构建的应用程序部署到 Heroku。

我遵循了所有步骤。

当我尝试推送到 Heroku 时,出现以下错误:

Failed to compile.
./src/services/api/securities/index.ts
Cannot find file './keys' in './src/services/api/securities'.

我知道这是为什么。

'keys' 文件在我的 .gitignore 中。它包含敏感的 API 键,所以我希望 git 忽略它。

这是访问 index.ts fike

中的密钥的尝试
export * from './keys'

但似乎没有它 Heroku 就无法构建。

请帮忙。

这不是 Heroku 问题,任何平台都需要应用程序中所需的文件才能构建。

此外,不得将敏感数据(密钥文件)推送到 Git。您需要在需要密钥文件的应用程序中进行一些更改,从环境变量中读取所有这些属性,例如 process.env.{key_name},并在 Heroku 中设置此敏感 属性 在环境变量中。

勾选这个link

https://devcenter.heroku.com/articles/config-vars

希望你明白了。