简体   繁体   English

如何在 Heroku 的 React 项目上处理生产环境变量

[英]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上设置环境变量,见:

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.

相关问题 如何使用 AWS Amplify 和 Next.js 制作生产环境变量 - How to make production environmental variables with AWS Amplify and Next.js AWS Lambda:如何从配置中删除环境变量 - AWS Lambda: How To Remove Environmental Variables from Configuration 如何在 Jenkins 中将 AWS 凭证设置为环境变量 - How to set AWS credentials as Environmental variable in Jenkins 如何在 Spring 引导项目中的 Heroku 上使用 Google API 凭据 - How to use Google API credentials on Heroku in Spring Boot Project 如何在 React 中使用在 Google Cloud Run Dashboard 上声明的 ENV 变量 - How to use ENV Variables Declared on Google Cloud Run Dashboard in React React-router 没有在生产上工作 - React-router did not work on production 如何在 React 应用程序中处理 Firebase onAuthStateChanged 并相应地路由用户? - How to handle Firebase onAuthStateChanged in a React app and route users accordingly? 如何处理在 React JS 中登录 state 和 Firebase 的用户? - How to handle user logged in state in React JS and Firebase? 如何处理 CORS 错误,同时在 vue 项目中获取 firebase 实时数据库 API? - How to handle CORS error, while fetching firebase realtime database API in vue project? 如何在不从 cli 重新部署 function 的情况下更改 firebase function 的环境变量 (functions.config()) - How to change a environmental variable (functions.config()) of a firebase function, without redeploying the function from the cli
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM