feat: expose backend url in admin options (#7370)

This commit is contained in:
Oli Juhl authored and GitHub committed 2024-05-20 11:24:15 +02:00
1 parent 028f63eb63
commit c9bffdfecb
3 files changed
+8 -7

No files matched your search

@@ -17,6 +17,8 @@ export async function getViteConfig(
const root = path.resolve(__dirname, "./") const root = path.resolve(__dirname, "./")
const backendUrl = options.backendUrl ?? ""
return { return {
root: path.resolve(__dirname, "./"), root: path.resolve(__dirname, "./"),
base: options.path, base: options.path,
@@ -29,12 +31,7 @@ export async function getViteConfig(
}, },
define: { define: {
__BASE__: JSON.stringify(options.path), __BASE__: JSON.stringify(options.path),
/** __BACKEND_URL__: JSON.stringify(backendUrl),
* TODO: Accept backend url from config to support hosting the admin elsewhere.
* The empty string should be the default value, as that ensures that requests
* are made to the server that serves the admin dashboard.
*/
__BACKEND_URL__: JSON.stringify(""),
}, },
server: { server: {
open: true, open: true,
+1 -1
View File
@@ -1,4 +1,4 @@
import { AdminOptions } from "@medusajs/types" import { AdminOptions } from "@medusajs/types"
export type BundlerOptions = Required<Pick<AdminOptions, "outDir" | "path">> & export type BundlerOptions = Required<Pick<AdminOptions, "outDir" | "path">> &
Pick<AdminOptions, "vite"> Pick<AdminOptions, "vite" | "backendUrl">
@@ -33,6 +33,10 @@ export type AdminOptions = {
* The default value is `./build`. * The default value is `./build`.
*/ */
outDir?: string outDir?: string
/**
* The URL of your Medusa server. Defaults to an empty string, which means requests will hit the same server that serves the dashboard.
*/
backendUrl?: string
/** /**
* Configure the Vite configuration for the admin dashboard. This function receives the default Vite configuration * Configure the Vite configuration for the admin dashboard. This function receives the default Vite configuration
* and returns the modified configuration. The default value is `undefined`. * and returns the modified configuration. The default value is `undefined`.