feat: expose backend url in admin options (#7370)
This commit is contained in:
@@ -17,6 +17,8 @@ export async function getViteConfig(
|
||||
|
||||
const root = path.resolve(__dirname, "./")
|
||||
|
||||
const backendUrl = options.backendUrl ?? ""
|
||||
|
||||
return {
|
||||
root: path.resolve(__dirname, "./"),
|
||||
base: options.path,
|
||||
@@ -29,12 +31,7 @@ export async function getViteConfig(
|
||||
},
|
||||
define: {
|
||||
__BASE__: JSON.stringify(options.path),
|
||||
/**
|
||||
* 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(""),
|
||||
__BACKEND_URL__: JSON.stringify(backendUrl),
|
||||
},
|
||||
server: {
|
||||
open: true,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AdminOptions } from "@medusajs/types"
|
||||
|
||||
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`.
|
||||
*/
|
||||
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
|
||||
* and returns the modified configuration. The default value is `undefined`.
|
||||
|
||||
Reference in New Issue
Block a user