React

환경변수이름에 REACT_APP_ 변수 이름 사용 이유

고수트 2023. 3. 26. 21:00
반응형

변수 설정을 위해 .env 파일에 환경변수 이름을 설정할 때가 있다.

이때 리액트의 경우 환경변수 이름은 REACT_APP_ 으로 시작해야 인식이 되는데 그이유를 홈페이지에 찾아보면 아래와 같이 나온다.

간단히 번역하면 우연히 같은 이름을 가진 시스템의 private key 가 노출 될 수 있으니 이를 피하기 위해 REACT_APP_ 으로 사용한다. 

Note: You must create custom environment variables beginning with REACT_APP_. Any other variables except NODE_ENV will be ignored to avoid accidentally exposing a private key on the machine that could have the same name. Changing any environment variables will require you to restart the development server if it is running.

 

Using dotenv .env config file correctly · Issue #865 · facebook/create-react-app

Description How the .env file and imports should be setup for the project correctly as currently the build is breaking. Expected behavior add .env file with config in root npm install --save dotenv...

github.com

 

 

반응형