docs: document using env vars in plugins (#12618)

This commit is contained in:
Shahed Nasser
2025-05-26 18:50:05 +03:00
committed by GitHub
parent 1f5f50010a
commit e7cf2219b6
7 changed files with 18015 additions and 17797 deletions
@@ -107,7 +107,7 @@ To ensure that the correct `.env` file is loaded as shown in the table above, on
Since the Medusa Admin is built on top of [Vite](https://vite.dev/), you prefix the environment variables you want to use in a widget or UI route with `VITE_`. Then, you can access or use them with the `import.meta.env` object.
Learn more in [this documentation](../admin/environment-variables/page.mdx).
Learn more in the [Admin Environment Variables](../admin/environment-variables/page.mdx) chapter.
---
@@ -124,111 +124,187 @@ You should opt for setting configurations in `medusa-config.ts` where possible.
<Table>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Environment Variable</Table.HeaderCell>
<Table.HeaderCell>Description</Table.HeaderCell>
<Table.HeaderCell>Default</Table.HeaderCell>
<Table.HeaderCell>
Environment Variable
</Table.HeaderCell>
<Table.HeaderCell>
Description
</Table.HeaderCell>
<Table.HeaderCell>
Default
</Table.HeaderCell>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>`HOST`</Table.Cell>
<Table.Cell>The host to run the Medusa application on.</Table.Cell>
<Table.Cell> `localhost` </Table.Cell>
<Table.Cell>
`HOST`
</Table.Cell>
<Table.Cell>
The host to run the Medusa application on.
</Table.Cell>
<Table.Cell>
`localhost`
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`PORT`</Table.Cell>
<Table.Cell>The port to run the Medusa application on.</Table.Cell>
<Table.Cell> `9000` </Table.Cell>
<Table.Cell>
`PORT`
</Table.Cell>
<Table.Cell>
The port to run the Medusa application on.
</Table.Cell>
<Table.Cell>
`9000`
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`DATABASE_URL`</Table.Cell>
<Table.Cell>
`DATABASE_URL`
</Table.Cell>
<Table.Cell>
The URL to connect to the PostgreSQL database. Only used if [projectConfig.databaseUrl](../../configurations/medusa-config/page.mdx#databaseurl) isn't set in `medusa-config.ts`.
</Table.Cell>
<Table.Cell> `postgres://localhost/medusa-starter-default` </Table.Cell>
<Table.Cell>
`postgres://localhost/medusa-starter-default`
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`STORE_CORS`</Table.Cell>
<Table.Cell>
`STORE_CORS`
</Table.Cell>
<Table.Cell>
URLs of storefronts that can access the Medusa backend's Store APIs. Only used if [projectConfig.http.storeCors](../../configurations/medusa-config/page.mdx#http-storeCors-1-1) isn't set in `medusa-config.ts`.
</Table.Cell>
<Table.Cell> `http://localhost:8000` </Table.Cell>
<Table.Cell>
`http://localhost:8000`
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`ADMIN_CORS`</Table.Cell>
<Table.Cell>
URLs of admin dashboards that can access the Medusa backend's Admin APIs. Only used if [projectConfig.http.adminCors](../../configurations/medusa-config/page.mdx#http-adminCors-1-2) isn't set in `medusa-config.ts`.
</Table.Cell>
<Table.Cell> `http://localhost:7000,http://localhost:7001,http://localhost:5173` </Table.Cell>
<Table.Cell>
`http://localhost:7000,http://localhost:7001,http://localhost:5173`
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`AUTH_CORS`</Table.Cell>
<Table.Cell>
URLs of clients that can access the Medusa backend's authentication routes. Only used if [projectConfig.http.authCors](../../configurations/medusa-config/page.mdx#http-authCors-1-0) isn't set in `medusa-config.ts`.
</Table.Cell>
<Table.Cell> `http://localhost:7000,http://localhost:7001,http://localhost:5173` </Table.Cell>
<Table.Cell>
`http://localhost:7000,http://localhost:7001,http://localhost:5173`
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`JWT_SECRET`</Table.Cell>
<Table.Cell>
A random string used to create authentication tokens in the http layer. Only used if [projectConfig.http.jwtSecret](../../configurations/medusa-config/page.mdx#http-jwtSecret-1-3) isn't set in `medusa-config.ts`.
</Table.Cell>
<Table.Cell> \- </Table.Cell>
<Table.Cell>
\-
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`COOKIE_SECRET`</Table.Cell>
<Table.Cell>
`COOKIE_SECRET`
</Table.Cell>
<Table.Cell>
A random string used to create cookie tokens in the http layer. Only used if [projectConfig.http.cookieSecret](../../configurations/medusa-config/page.mdx#http-cookieSecret-1-5) isn't set in `medusa-config.ts`.
</Table.Cell>
<Table.Cell> \- </Table.Cell>
<Table.Cell>
\-
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`MEDUSA_BACKEND_URL`</Table.Cell>
<Table.Cell>
`MEDUSA_BACKEND_URL`
</Table.Cell>
<Table.Cell>
The URL to the Medusa backend. Only used if [admin.backendUrl](../../configurations/medusa-config/page.mdx#backendurl) isn't set in `medusa-config.ts`.
</Table.Cell>
<Table.Cell> \- </Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`DB_HOST`</Table.Cell>
<Table.Cell>The host for the database. It's used when generating migrations for a plugin, and when running integration tests.</Table.Cell>
<Table.Cell>`localhost`</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`DB_USERNAME`</Table.Cell>
<Table.Cell>The username for the database. It's used when generating migrations for a plugin, and when running integration tests.</Table.Cell>
<Table.Cell> \- </Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`DB_PASSWORD`</Table.Cell>
<Table.Cell>The password for the database user. It's used when generating migrations for a plugin, and when running integration tests.</Table.Cell>
<Table.Cell> \- </Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`DB_TEMP_NAME`</Table.Cell>
<Table.Cell>The database name to create for integration tests.</Table.Cell>
<Table.Cell> \- </Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`LOG_LEVEL`</Table.Cell>
<Table.Cell>
The allowed levels to log. Learn more in [this doumentation](../../debugging-and-testing/logging/page.mdx#log-levels).
\-
</Table.Cell>
<Table.Cell>`silly`</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`LOG_FILE`</Table.Cell>
<Table.Cell>
The file to save logs in. By default, logs aren't saved in any file. Learn more in [this documentation](../../debugging-and-testing/logging/page.mdx).
`DB_HOST`
</Table.Cell>
<Table.Cell>
The host for the database. It's used when generating migrations for a plugin, and when running integration tests.
</Table.Cell>
<Table.Cell>
`localhost`
</Table.Cell>
<Table.Cell> \- </Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`MEDUSA_DISABLE_TELEMETRY`</Table.Cell>
<Table.Cell>
Whether to disable analytics data collection. Learn more in [this documentation](../../resources/usage/page.mdx).
`DB_USERNAME`
</Table.Cell>
<Table.Cell>
The username for the database. It's used when generating migrations for a plugin, and when running integration tests.
</Table.Cell>
<Table.Cell>
\-
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`DB_PASSWORD`
</Table.Cell>
<Table.Cell>
The password for the database user. It's used when generating migrations for a plugin, and when running integration tests.
</Table.Cell>
<Table.Cell>
\-
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`DB_TEMP_NAME`
</Table.Cell>
<Table.Cell>
The database name to create for integration tests.
</Table.Cell>
<Table.Cell>
\-
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`LOG_LEVEL`
</Table.Cell>
<Table.Cell>
The allowed levels to log. Learn more in the [Logging](../../debugging-and-testing/logging/page.mdx#log-levels) chapter.
</Table.Cell>
<Table.Cell>
`silly`
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`LOG_FILE`
</Table.Cell>
<Table.Cell>
The file to save logs in. By default, logs aren't saved in any file. Learn more in the [Logging](../../debugging-and-testing/logging/page.mdx) chapter.
</Table.Cell>
<Table.Cell>
\-
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`MEDUSA_DISABLE_TELEMETRY`
</Table.Cell>
<Table.Cell>
Whether to disable analytics data collection. Learn more in the [Usage](../../resources/usage/page.mdx) chapter.
</Table.Cell>
<Table.Cell>
\-
</Table.Cell>
<Table.Cell> \- </Table.Cell>
</Table.Row>
</Table.Body>
</Table>