docs: add sections on predefined environment and global variables (#11510)

This commit is contained in:
Shahed Nasser
2025-02-18 19:12:38 +02:00
committed by GitHub
parent 7f7316c127
commit 062805d533
4 changed files with 7844 additions and 7667 deletions
@@ -138,6 +138,16 @@ You can also send requests to custom routes as explained in the [JS SDK referenc
---
## Global Variables in Admin Customizations
In your admin customizations, you can use the following global variables:
- `__BASE__`: The base path of the Medusa Admin, as set in the [admin.path](!resources!/references/medusa-config#path) configuration in `medusa-config.ts`.
- `__BACKEND_URL__`: The URL to the Medusa backend, as set in the [admin.backendUrl](!resources!/references/medusa-config#backendurl) configuration in `medusa-config.ts`.
- `__STOREFRONT_URL__`: The URL to the storefront, as set in the [admin.storefrontUrl](!resources!/references/medusa-config#storefrontUrl) configuration in `medusa-config.ts`.
---
## Routing Functionalities
To navigate or link to other pages, or perform other routing functionalities, use the [react-router-dom](https://reactrouter.com/en/main) package. It's installed in your project through the Medusa Admin.
@@ -108,3 +108,127 @@ 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).
---
## Predefined Medusa Environment Variables
The Medusa application uses the following predefined environment variables that you can set:
<Note title="Tip">
You should opt for setting configurations in `medusa-config.ts` where possible. For a full list of Medusa configurations, refer to [this documenation](!resources!/references/medusa-config).
</Note>
<Table>
<Table.Header>
<Table.Row>
<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.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.Row>
<Table.Row>
<Table.Cell>`DATABASE_URL`</Table.Cell>
<Table.Cell>
The URL to connect to the PostgreSQL database. Only used if [projectConfig.databaseUrl](!resources!/references/medusa-config#databaseurl) isn't set in `medusa-config.ts`.
</Table.Cell>
<Table.Cell> `postgres://localhost/medusa-starter-default` </Table.Cell>
</Table.Row>
<Table.Row>
<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](!resources!/references/medusa-config#http-storeCors-1-1) isn't set in `medusa-config.ts`.
</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](!resources!/references/medusa-config#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.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](!resources!/references/medusa-config#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.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](!resources!/references/medusa-config#http-jwtSecret-1-3) isn't set in `medusa-config.ts`.
</Table.Cell>
<Table.Cell> \- </Table.Cell>
</Table.Row>
<Table.Row>
<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](!resources!/references/medusa-config#http-cookieSecret-1-5) isn't set in `medusa-config.ts`.
</Table.Cell>
<Table.Cell> \- </Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>`MEDUSA_BACKEND_URL`</Table.Cell>
<Table.Cell>
The URL to the Medusa backend. Only used if [admin.backendUrl](!resources!/references/medusa-config#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).
</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 documenation](!resources!/usage).
</Table.Cell>
<Table.Cell> \- </Table.Cell>
</Table.Row>
</Table.Body>
</Table>
+3 -3
View File
@@ -50,7 +50,7 @@ export const generatedEditDates = {
"app/learn/fundamentals/scheduled-jobs/execution-number/page.mdx": "2024-10-21T13:30:21.371Z",
"app/learn/fundamentals/api-routes/parameters/page.mdx": "2025-02-14T08:34:03.184Z",
"app/learn/fundamentals/api-routes/http-methods/page.mdx": "2024-10-21T13:30:21.367Z",
"app/learn/fundamentals/admin/tips/page.mdx": "2025-02-05T09:07:52.584Z",
"app/learn/fundamentals/admin/tips/page.mdx": "2025-02-18T15:28:39.264Z",
"app/learn/fundamentals/api-routes/cors/page.mdx": "2024-12-09T13:04:04.357Z",
"app/learn/fundamentals/admin/ui-routes/page.mdx": "2024-12-09T16:44:40.198Z",
"app/learn/fundamentals/api-routes/middlewares/page.mdx": "2025-02-12T17:05:20.708Z",
@@ -102,7 +102,7 @@ export const generatedEditDates = {
"app/learn/introduction/architecture/page.mdx": "2025-01-16T10:25:10.780Z",
"app/learn/fundamentals/data-models/infer-type/page.mdx": "2024-12-09T15:54:08.713Z",
"app/learn/fundamentals/custom-cli-scripts/seed-data/page.mdx": "2024-12-09T14:38:06.385Z",
"app/learn/fundamentals/environment-variables/page.mdx": "2025-02-05T09:15:49.196Z",
"app/learn/fundamentals/environment-variables/page.mdx": "2025-02-18T15:29:37.717Z",
"app/learn/build/page.mdx": "2024-12-09T11:05:17.383Z",
"app/learn/deployment/general/page.mdx": "2024-11-25T14:33:50.439Z",
"app/learn/fundamentals/workflows/multiple-step-usage/page.mdx": "2024-11-25T16:19:32.169Z",
@@ -116,6 +116,6 @@ export const generatedEditDates = {
"app/learn/customization/reuse-customizations/page.mdx": "2025-01-22T10:01:57.665Z",
"app/learn/update/page.mdx": "2025-01-27T08:45:19.030Z",
"app/learn/fundamentals/module-links/query-context/page.mdx": "2025-02-12T16:59:20.963Z",
"app/learn/fundamentals/admin/environment-variables/page.mdx": "2025-02-06T13:29:46.800Z",
"app/learn/fundamentals/admin/environment-variables/page.mdx": "2025-02-18T14:48:17.731Z",
"app/learn/fundamentals/api-routes/parse-body/page.mdx": "2025-02-14T08:32:25.596Z"
}
File diff suppressed because it is too large Load Diff