docs: add buffer example in workflows + tip for type error in admin global variables (#13124)
This commit is contained in:
@@ -65,10 +65,16 @@ If you receive a type error on `import.meta.env`, create the file `src/admin/vit
|
||||
|
||||
```ts title="src/admin/vite-env.d.ts"
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare const __BASE__: string
|
||||
declare const __BACKEND_URL__: string
|
||||
declare const __STOREFRONT_URL__: string
|
||||
```
|
||||
|
||||
This file tells TypeScript to recognize the `import.meta.env` object and enhances the types of your custom environment variables.
|
||||
|
||||
Note that the `__BASE__`, `__BACKEND_URL__`, and `__STOREFRONT_URL__` variables are global variables available in your admin customizations. Learn more in the [Tips for Admin Customizations](../tips/page.mdx#global-variables-in-admin-customizations) chapter.
|
||||
|
||||
---
|
||||
|
||||
## Check Node Environment in Admin Customizations
|
||||
@@ -122,3 +128,13 @@ export const config = defineWidgetConfig({
|
||||
|
||||
export default ProductWidget
|
||||
```
|
||||
|
||||
To fix possible type errors, create the file `src/admin/vite-env.d.ts` and add the global variables:
|
||||
|
||||
```ts title="src/admin/vite-env.d.ts"
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare const __BACKEND_URL__: string
|
||||
declare const __BASE__: string
|
||||
declare const __STOREFRONT_URL__: string
|
||||
```
|
||||
@@ -170,6 +170,16 @@ In your admin customizations, you can use the following global variables:
|
||||
- `__BACKEND_URL__`: The URL to the Medusa backend, as set in the [admin.backendUrl](../../../configurations/medusa-config/page.mdx#backendurl) configuration in `medusa-config.ts`.
|
||||
- `__STOREFRONT_URL__`: The URL to the storefront, as set in the [admin.storefrontUrl](../../../configurations/medusa-config/page.mdx#storefrontUrl) configuration in `medusa-config.ts`.
|
||||
|
||||
If you get type errors while using these variables, you can create the file `src/admin/vite-env.d.ts` with the following content:
|
||||
|
||||
```ts title="src/admin/vite-env.d.ts"
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare const __BASE__: string
|
||||
declare const __BACKEND_URL__: string
|
||||
declare const __STOREFRONT_URL__: string
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Admin Translations
|
||||
|
||||
Reference in New Issue
Block a user