Skip to content
Merged
Changes from 4 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
16 changes: 16 additions & 0 deletions docs/api-reference/next/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ The introduction of the `307` status code means that the request method is prese

The `redirect()` method uses a `307` by default, instead of a `302` temporary redirect, meaning your requests will _always_ be preserved as `POST` requests.

### Accessing environment variables

`process.env` can be used to access [environment variables](docs/basic-features/environment-variables.md) from Middleware. However, these are evaluated at build time so only environment variables _actually_ used will be included.

Any variables in `process.env` must be accessed directly, and **cannot** be destructured:

```ts
// This will not work
const { NODE_ENV } = process.env
console.log(NODE_ENV)
// Empty object
console.log(process.env)
// Accessed directly, and not destructured works
console.log(process.env.NODE_ENV)
```

## Related

<div class="card">
Expand Down