Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/content/docs/ko/guides/environment-variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ PUBLIC_POKEAPI="https://pokeapi.co/api/v2"

## 환경 변수 가져오기

Vite에서는 `process.env`를 사용하는 대신, ES2020에 추가된 `import.meta` 기능을 사용하는 `import.meta.env`를 사용합니다.
Astro의 환경 변수는 process.env 대신 [ES2020에 추가된 import.meta 기능](https://tc39.es/ecma262/2020/#prod-ImportMeta)의 import.meta.env를 통해 사용할 수 있습니다.

예를 들어 `import.meta.env.PUBLIC_POKEAPI`를 사용하여 `PUBLIC_POKEAPI` 환경 변수를 가져올 수 있습니다.

Expand All @@ -98,10 +98,6 @@ const data = await db(import.meta.env.DB_PASSWORD);
const data = fetch(`${import.meta.env.PUBLIC_POKEAPI}/pokemon/squirtle`);
```

:::caution
Vite는 `import.meta.env`를 정적으로 대체하기 때문에 `import.meta.env[key]`와 같은 동적 키를 사용할 수 없습니다.
:::

SSR을 사용하는 경우, 사용 중인 SSR 어댑터를 통해 런타임 시 환경 변수를 사용할 수 있습니다. 대부분의 어댑터는 `process.env`를 통해 환경 변수를 사용하지만 일부 어댑터는 다르게 동작합니다. Deno 어댑터의 경우 `Deno.env.get()` 함수를 사용합니다. [Cloudflare 런타임 사용](/ko/guides/integrations-guide/cloudflare/#cloudflare-runtime)에서 Cloudflare 어댑터가 환경 변수를 처리하는 방법을 알아보세요. Astro는 먼저 서버 환경에서 변수를 확인하고 변수가 존재하지 않으면 .env 파일에서 해당 변수를 찾습니다.

## TypeScript 자동 완성
Expand Down