You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/deploy-web/README.md
+30-18
Original file line number
Diff line number
Diff line change
@@ -14,21 +14,33 @@ The website should be accessible: [http://localhost:3000/](http://localhost:3000
14
14
15
15
## Environment Variables
16
16
17
-
When running the api locally the following environment variables can be set in a `.env.local` file.
18
-
19
-
It is possible to run the website locally without any environment variables, but the login feature will be unavailable.
20
-
21
-
|Name|Value|Note|
22
-
|-|-|-
23
-
|NEXT_PUBLIC_GA_MEASUREMENT_ID|ex: `G-87H3KK3D`|Google Analytics ID
24
-
|NEXT_PUBLIC_SENTRY_DSN|ex: `"https://[email protected]/1234"`|[Sentry DSN](https://docs.sentry.io/product/sentry-basics/dsn-explainer/) used when initializing Sentry in [sentry.client.config.js](./sentry.client.config.js) and [sentry.server.config.js](./sentry.server.config.js)
25
-
|AUTH0_SECRET||
26
-
|AUTH0_BASE_URL||
27
-
|AUTH0_ISSUER_BASE_URL||
28
-
|AUTH0_CLIENT_ID||
29
-
|AUTH0_CLIENT_SECRET||
30
-
|AUTH0_AUDIENCE||
31
-
|AUTH0_SCOPE||
32
-
|AUTH0_M2M_DOMAIN||
33
-
|AUTH0_M2M_CLIENT_ID||
34
-
|AUTH0_M2M_CLIENT_SECRET||
17
+
### Overview
18
+
Environment variables in this Next.js app follow the standard Next.js behavior, as documented in the [Next.js environment variables documentation](https://nextjs.org/docs/basic-features/environment-variables). This means that files like `.env.local` or `.env.production` will be automatically loaded based on the environment in which the app is running.
19
+
20
+
However, we have extended this functionality to support more granular environment-specific configurations. Environment variables are stored in the `./env` directory, where multiple `.env` files exist for different deployment environments (stages):
21
+
22
+
-`.env` - Loaded for any environment
23
+
-`.env.production` - Loaded for the production stage
24
+
-`.env.staging` - Loaded for the staging stage
25
+
26
+
### How Environment Variables Are Loaded
27
+
We use **dotenvx** to manage and load environment variables. This allows us to take advantage of its features, such as **variable interpolation** (i.e., using other environment variables within variable values).
28
+
29
+
### Validation with Zod
30
+
Environment variables are validated using **Zod** schemas, ensuring that all required variables are present and have valid values. The validation logic can be found in the file `src/config/env-config.schema.ts`.
31
+
32
+
We use two separate Zod schemas:
33
+
-**Static Build-Time Schema**: Validates variables at build time. If any variables are missing or invalid during the build process, the build will fail.
34
+
-**Dynamic Server Runtime Schema**: Validates variables at server startup. If any variables are missing or invalid at this stage, the server will fail to start.
35
+
36
+
This validation ensures that both build and runtime configurations are secure and complete before the app runs.
37
+
38
+
### App Configuration
39
+
App configurations, including environment variables, are located in the `src/config` directory. In our setup:
40
+
-**Environment configs** are handled separately from **hardcoded configs**.
41
+
- Hardcoded configs are organized by domain to maintain a clear structure and separation of concerns.
42
+
43
+
### Sample Environment Variables
44
+
All environment variables required for the app, along with their expected structure and types, can be found in the `env/.env.sample` file. This sample file serves as a template for setting up your environment variables and ensures that all necessary variables are accounted for in each environment.
45
+
46
+
By organizing environment variables and configuration this way, we ensure a consistent, safe, and scalable approach to managing different deployment environments.
0 commit comments