mirror of
https://github.com/labring/laf.git
synced 2026-01-25 16:07:45 +00:00
* doc: add international English section * doc: del operator.md * doc: some old error * doc: fix path errors * doc: modify the default readme language * doc: Part of the internationalization of changes * doc: keep English readme * doc: delete readme_en.md
30 lines
874 B
Markdown
30 lines
874 B
Markdown
---
|
|
title: Using Environment Variables in Cloud Functions
|
|
---
|
|
|
|
# {{ $frontmatter.title }}
|
|
|
|
## Adding Environment Variables
|
|
|
|
1. First, click on the small gear button at the bottom left corner of the page to open the application settings page.
|
|
2. Next, in the popped-up application settings interface, click on "Environment Variables" and enter your environment variable on a new line below. The format should be: `NAME='value'`
|
|
3. Click on "Update" to make it effective.
|
|
|
|
## Using Environment Variables
|
|
|
|
Once the environment variables are added, you can use them in any cloud function by accessing `process.env`.
|
|
|
|
:::tip
|
|
`cloud.env` is deprecated.
|
|
:::
|
|
|
|
```typescript
|
|
import cloud from '@lafjs/cloud'
|
|
|
|
export async function main(ctx: FunctionContext) {
|
|
|
|
const env = process.env
|
|
console.log(env)
|
|
// All the environment variables are available in process.env
|
|
}
|
|
``` |