Firebase에서 환경 변수 설정 방법
2203 단어 firebase-toolsJavaScriptFirebase
Firebase의 환경 변수 요약
Firebase에서는 API 키 등 외부에 공개하지 않으려는 정보를 환경 변수로 설정할 수 있습니다.인상으로는
heroku
등처럼간단하게설정할 수 있어편리하다.비록 거의 모두 공식 문서에 쓰였지만, 비망록도 겸하여 보존해 두었다
보충하여 기록하다
Firebase 공식 문서|환경 설정
단계
firebase login
cd ~/workplace/hoge-projects
firebase functions:config:set gmail.email="[email protected]" gmail.password="yourpassword"
firebase functions:config:get
설정된 환경 변수의 일람은 다음과 같다.{
"gmail": {
"password": "yourpassword",
"email": "[email protected]"
}
}
functions.config()
를 통해 환경 변수에 액세스할 수 있습니다.이후 자신이 설정한 속성을 지정하여 꺼낼 수 있습니다.
index.js
const gmailEmail = encodeURIComponent(functions.config().gmail.email);
const gmailPassword = encodeURIComponent(functions.config().gmail.password);
마지막
firebase
의 경우api key와 app ID를 복사하는 경우도 있는데 이것도 환경 변수로 처리하는 것이 좋겠죠?그렇게 생각했지만 이런 기사를 발견했어요.이 내용에 의하면

구글apis의 인증 정보에서 개별 Firebase 프로젝트의 인증 정보가 누설되지 않으면 불법으로 이용되지 않는다.
Reference
이 문제에 관하여(Firebase에서 환경 변수 설정 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/nerdyboy_cool/items/695c8af7ca8d22761927텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)