diff --git a/src/config/environments.ts b/src/config/environments.ts index 6b88f4b1..88bf87a2 100644 --- a/src/config/environments.ts +++ b/src/config/environments.ts @@ -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; };