-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f73c1b1
commit 189938e
Showing
1 changed file
with
7 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
const { VITE_BASE_URL, VITE_KAKAO_REST_API_KEY, VITE_KAKAO_REDIRECT_URI } = import.meta.env; | ||
|
||
export const environments = { | ||
baseUrlEnv: () => checkEnv(VITE_BASE_URL), | ||
kakaoRestApiKeyEnv: () => checkEnv(VITE_KAKAO_REST_API_KEY), | ||
kakaoRedirectUriEnv: () => checkEnv(VITE_KAKAO_REDIRECT_URI), | ||
baseUrlEnv: () => getEnvVariable('VITE_BASE_URL'), | ||
kakaoRestApiKeyEnv: () => getEnvVariable('VITE_KAKAO_REST_API_KEY'), | ||
kakaoRedirectUriEnv: () => getEnvVariable('VITE_KAKAO_REDIRECT_URI'), | ||
}; | ||
|
||
const checkEnv = (envKey: string) => { | ||
if (!envKey) { | ||
const getEnvVariable = (envKey: string) => { | ||
const envVariable = import.meta.env[envKey]; | ||
if (!envVariable) { | ||
throw new Error(`${envKey} 환경변수가 설정돼있지 않습니다.`); | ||
} | ||
return envKey; | ||
return envVariable; | ||
}; |