docs: document using env vars in plugins (#12618)
This commit is contained in:
@@ -42,7 +42,7 @@ For admin customizations, create this file at `src/admin/lib/config.ts`.
|
||||
</Note>
|
||||
|
||||
<CodeTabs group="sdk-project">
|
||||
<CodeTab label="Admin" value="admin">
|
||||
<CodeTab label="Admin (Medusa project)" value="admin-medusa-project">
|
||||
|
||||
```ts title="src/admin/lib/config.ts"
|
||||
import Medusa from "@medusajs/js-sdk"
|
||||
@@ -54,6 +54,21 @@ export const sdk = new Medusa({
|
||||
type: "session",
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="Admin (Medusa Plugin)" value="admin-medusa-plugin">
|
||||
|
||||
```ts title="src/admin/lib/config.ts"
|
||||
import Medusa from "@medusajs/js-sdk"
|
||||
|
||||
export const sdk = new Medusa({
|
||||
baseUrl: __BACKEND_URL__ || "/",
|
||||
debug: import.meta.env.DEV,
|
||||
auth: {
|
||||
type: "session",
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
@@ -80,7 +95,7 @@ export const sdk = new Medusa({
|
||||
|
||||
<Note title="Tip">
|
||||
|
||||
In the Medusa Admin you use `import.meta.env` to access environment variables becaues the Medusa Admin is built on top of [Vite](https://vitejs.dev/). Learn more in [this documentation](!docs!/learn/fundamentals/admin/environment-variables).
|
||||
In Medusa Admin customizations that are created in a Medusa project, you use `import.meta.env` to access environment variables, whereas in customizations built in a Medusa plugin, you use the global variable `__BACKEND_URL__` to access the backend URL. You can learn more in the [Admin Environment Variables](!docs!/learn/fundamentals/admin/environment-variables) chapter.
|
||||
|
||||
</Note>
|
||||
|
||||
|
||||
@@ -2168,7 +2168,7 @@ export const generatedEditDates = {
|
||||
"app/commerce-modules/store/links-to-other-modules/page.mdx": "2025-04-17T16:03:16.419Z",
|
||||
"app/examples/page.mdx": "2025-04-17T08:50:17.036Z",
|
||||
"app/medusa-cli/commands/build/page.mdx": "2024-11-11T11:00:49.665Z",
|
||||
"app/js-sdk/page.mdx": "2025-03-28T09:50:07.617Z",
|
||||
"app/js-sdk/page.mdx": "2025-05-26T15:08:16.590Z",
|
||||
"references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.apiKey/page.mdx": "2025-05-20T07:51:40.924Z",
|
||||
"references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.campaign/page.mdx": "2025-05-20T07:51:40.925Z",
|
||||
"references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.claim/page.mdx": "2025-05-20T07:51:40.925Z",
|
||||
|
||||
Reference in New Issue
Block a user