Skip to content

Commit

Permalink
docs(nx-dev): update define-environment-variables.md changed NX_ to… (
Browse files Browse the repository at this point in the history
#23397)

## Current Behavior
Incorrect environment variable prefix `NX_` in docs.

## Expected Behavior
Correct environment variable prefix `NX_PUBLIC_` in docs.

## Related Issue(s)
#23362
  • Loading branch information
barrymichaeldoyle authored May 15, 2024
1 parent a2a7d7e commit 38a947f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/shared/guides/define-environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ it will ignore it. It does this for two reasons:

For example:

1. `apps/my-app/.env.local` contains `NX_API_URL=http://localhost:3333`
2. `apps/my-app/.env` contains `NX_API_URL=https://api.example.com`
1. `apps/my-app/.env.local` contains `NX_PUBLIC_API_URL=http://localhost:3333`
2. `apps/my-app/.env` contains `NX_PUBLIC_API_URL=https://api.example.com`
3. Nx will first load the variables from `apps/my-app/.env.local` into the process. When it tries to load the variables
from `apps/my-app/.env`, it will notice that `NX_API_URL` already exists, so it will ignore it.
from `apps/my-app/.env`, it will notice that `NX_PUBLIC_API_URL` already exists, so it will ignore it.

We recommend nesting your **app** specific `env` files in `apps/your-app`, and creating workspace/root level `env` files
for workspace-specific settings (like the [Nx Cloud token](/ci/recipes/security/access-tokens)).
Expand All @@ -68,17 +68,17 @@ In Unix systems, we need to set the environment variables before calling a comma
Let's say that we want to define an API URL for the application to use:

```shell
NX_API_URL=http://localhost:3333 nx build myapp
NX_PUBLIC_API_URL=http://localhost:3333 nx build myapp
```

**Windows (cmd.exe)**

```shell
set "NX_API_URL=http://localhost:3333" && nx build myapp
set "NX_PUBLIC_API_URL=http://localhost:3333" && nx build myapp
```

**Windows (Powershell)**

```shell
($env:NX_API_URL = "http://localhost:3333") -and (nx build myapp)
($env:NX_PUBLIC_API_URL = "http://localhost:3333") -and (nx build myapp)
```

0 comments on commit 38a947f

Please sign in to comment.