codestates / codestates/book-log

[Error] 클라이언트에서 환경변수를 가져오지 못함

Open
#62 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1
Forks
5
PR merge metrics
No merged PRs in 30d

Description

### **어떤 에러인가요?**

- 클라이언트에서 환경변수에 대한 설정을 다 했는데 코드에서 환경변수를 불러오지 못함

### **에러 메시지**

- 설정한 환경변수에 대해 모두 `undefined`가 출력됨

### **에러 핸들링 방법**

- 환경 변수에 필요한 모든 설정을 한 것 같은데 `console.log(process.env)`를 찍어봐도 설정한 환경변수가 들어있지 않았다.
- `react environment variable`로 구글링을 했고 `create-react-app`으로 생성한 리액트 앱에서 환경변수를 설정할 때는 `REACT_APP_`으로 시작하는 변수명을 사용해야된다는 것을 알았고, 이를 적용해서 에러를 해결할 수 있었다.

### **에러 핸들링을 위해 참고한 레퍼런스 링크**

[Adding Custom Environment Variables](https://create-react-app.dev/docs/adding-custom-environment-variables/)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.