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: docusaurus/docs/cms/configurations/environment.md
+17-2Lines changed: 17 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,8 @@ tags:
8
8
- environment
9
9
---
10
10
11
+
import SampleEnv from '/docs/snippets/sample-env.md'
12
+
11
13
# Environment configuration and variables
12
14
13
15
Strapi provides specific environment variable names. Defining them in an environment file (e.g., `.env`) will make these variables and their values available in your code.
@@ -29,14 +31,27 @@ Strapi provides the following environment variables:
29
31
|`NODE_ENV`| Type of environment where the application is running.<br/><br/>`production` enables specific behaviors (see <ExternalLinkto="https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production"text="Node.js documentation"/> for details) |`String`|`'development'`|
30
32
|`BROWSER`| Open the admin panel in the browser after startup |`Boolean`|`true`|
31
33
|`ENV_PATH`| Path to the file that contains your environment variables |`String`|`'./.env'`|
32
-
|`STRAPI_PLUGIN_I18N_INIT_LOCALE_CODE` <br/><br/>_Optional_| Initialization locale for the application, if the [Internationalization (i18n) plugin](/cms/features/internationalization) is installed and enabled on Content-Types (see [Configuration of i18n in production environments](/cms/features/internationalization#configuration)) |`String`|`'en'`|
34
+
|`STRAPI_PLUGIN_I18N_INIT_LOCALE_CODE` <br/><br/>_Optional_| Initialization locale for the application, if the [Internationalization (i18n) feature](/cms/features/internationalization) is installed and enabled on Content-Types (see [Configuration of i18n in production environments](/cms/features/internationalization#configuration)) |`String`|`'en'`|
33
35
|`STRAPI_ENFORCE_SOURCEMAPS`| Forces the bundler to emit source-maps, which is helpful for debugging errors in the admin app. |`boolean`|`false`|
34
36
|`FAST_REFRESH`|_(Only applies to webpack)_<br/>Use <ExternalLinkto="https://github.com/pmmmwh/react-refresh-webpack-plugin"text="react-refresh"/> to enable "Fast Refresh" for near-instant feedback while developing the Strapi admin panel. |`boolean`|`true`|
37
+
|`HOST`| Address the Strapi server listens on |`String`|`0.0.0.0`|
38
+
|`PORT`| Port used by the Strapi server |`Number`|`1337`|
39
+
|`APP_KEYS`| Comma-separated keys used to sign cookies and other secrets |`String`|`auto-generated`|
40
+
|`API_TOKEN_SALT`| Salt used when creating [API tokens](/cms/features/api-tokens)|`String`|`auto-generated`|
41
+
|`ADMIN_JWT_SECRET`| Secret for JWT tokens used in the admin panel |`String`|`auto-generated`|
42
+
|`JWT_SECRET`| Secret for JWT tokens generated by the [Users & Permissions](/cms/features/users-permissions) feature |`String`|`auto-generated`|
43
+
|`TRANSFER_TOKEN_SALT`| Salt used for transfer tokens by the [Data Management](/cms/features/data-management) feature |`String`|`auto-generated`|
44
+
|`DATABASE_CLIENT`| Database client to use (e.g., `sqlite`) |`String`|`sqlite`|
45
+
|`DATABASE_FILENAME`| Location of the SQLite database file |`String`|`.tmp/data.db`|
35
46
36
47
:::tip
37
48
Prefixing an environment variable name with `STRAPI_ADMIN_` exposes the variable to the admin front end (e.g., `STRAPI_ADMIN_MY_PLUGIN_VARIABLE` is accessible through `process.env.STRAPI_ADMIN_MY_PLUGIN_VARIABLE`).
38
49
:::
39
50
51
+
### Example `.env` file
52
+
53
+
<SampleEnv />
54
+
40
55
## Environment configurations
41
56
42
57
Configurations can be created with the following naming and structure conventions: `./config/env/{environment}/{filename}`. This is useful when you need specific static configurations for specific environments and using environment variables is not the best solution.
@@ -102,4 +117,4 @@ To learn deeper about how to use environment variables in your code, please refe
102
117
103
118
<CustomDocCardsWrapper>
104
119
<CustomDocCardicon="chalkboard-simple"title="Access and cast variables"description="Learn how to access and cast environment variables with the env() utility."link="/cms/configurations/guides/access-cast-environment-variables" />
Then you can create a `.env` file or directly set environment variables in your chosen deployment platform:
74
+
Strapi generates a `.env` file with default values when you create a new project. You can edit this file or set variables in your chosen deployment platform (see [example `.env` file](/cms/configurations/environment#example-env-file)):
The Strapi CLI generates an `.env` and an `.env.example` file when creating a new project. The files contain automatically-generated security keys and database settings similar to the following:
2
+
3
+
<Tabs>
4
+
<TabItemvalue="env-example"label=".env.example">
5
+
6
+
```env title=".env.example"
7
+
HOST=0.0.0.0
8
+
PORT=1337
9
+
APP_KEYS="toBeModified1,toBeModified2"
10
+
API_TOKEN_SALT=tobemodified
11
+
ADMIN_JWT_SECRET=tobemodified
12
+
TRANSFER_TOKEN_SALT=tobemodified
13
+
JWT_SECRET=tobemodified
14
+
ENCRYPTION_KEY=tobemodified
15
+
```
16
+
17
+
</TabItem>
18
+
<TabItemvalue="env"label=".env">
19
+
20
+
The variables might differ depending on options selected on project creation.
0 commit comments