简体   繁体   English

在 Heroku 上部署 Javascript 文件时使用环境变量

[英]Using environment Variables in Javascript file when deploying it on Heroku

I have an app written in JS,HTML and CSS which uses an API KEY.我有一个用 JS、HTML 和 CSS 编写的应用程序,它使用 API KEY。 I have used environment variables locally to use API KEY.我在本地使用了环境变量来使用 API KEY。 I have deployed it to heroku and while pushing to gitlab, I have added .env to gitignore and now after deployment, map is not visible because it can not access API KEY for maps.我已将其部署到 heroku 并在推送到 gitlab 时,我已将 .env 添加到 gitignore,现在部署后,地图不可见,因为它无法访问地图的 API KEY。 I want to ask how to use environment variables in production (in Heroku deployment)?我想问一下如何在生产中使用环境变量(在Heroku部署中)?

You can either use their online dashboard or the CLI to add env vars.您可以使用他们的在线仪表板或 CLI 添加环境变量。

See their docs here: https://devcenter.heroku.com/articles/config-vars#managing-config-vars在此处查看他们的文档: https : //devcenter.heroku.com/articles/config-vars#managing-config-vars

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM