[英]How to handle environmental variables on production on a React Project on Heroku
I have my Heroku connected to Github and my react project has a.env file with my Firebase config.我的 Heroku 连接到 Github,我的 React 项目有一个 .env 文件和我的 Firebase 配置。
I don't upload the.env to github for security reasons.出于安全原因,我没有将 .env 上传到 github。
But then, it doesn't get uploaded to Heroku and my project doesn't work.但是,它不会上传到 Heroku,我的项目也无法运行。 Or should it work anyway?
或者它应该工作吗? Without the.env it doesn't have access to the config like the apikey.
如果没有 the.env,它就无法像 apikey 那样访问配置。
So should I upload the.env file to Heroku?那么我应该把.env文件上传到Heroku吗? Is that safe?
那安全吗?
How am I supossed to handle this?我应该怎么处理这个?
You can set environment variables on Heroku, see:可以在Heroku上设置环境变量,见:
Reactjs is typically a client side framework. Reactjs 通常是客户端框架。 You are usually not doing SSR.
你通常不做SSR。 Are you certain you are doing SSR?
你确定你在做SSR? Because if are serving the static html,js,css files people already have access to your firebase config by looking at the browser source.
因为如果提供 static html,js,css 文件,人们已经可以通过查看浏览器源代码访问您的 firebase 配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.