diff --git a/.changeset/fair-zoos-watch.md b/.changeset/fair-zoos-watch.md new file mode 100644 index 0000000000..413a273f91 --- /dev/null +++ b/.changeset/fair-zoos-watch.md @@ -0,0 +1,6 @@ +--- +"@medusajs/admin-ui": patch +"@medusajs/medusa": patch +--- + +fix(medusa,admin-ui): Remove forced `backendUrl` from develop command. Allow specifying an alternative host value diff --git a/packages/admin-ui/src/node/actions/develop.ts b/packages/admin-ui/src/node/actions/develop.ts index 391ff98901..067cd0accc 100644 --- a/packages/admin-ui/src/node/actions/develop.ts +++ b/packages/admin-ui/src/node/actions/develop.ts @@ -22,10 +22,11 @@ export async function develop({ backend: "http://localhost:9000", develop: { open: true, + host: "localhost", port: 7001, logLevel: "error", stats: "normal", - allowedHosts: 'auto', + allowedHosts: "auto", }, }, }: DevelopArgs) { @@ -54,13 +55,16 @@ export async function develop({ const devServerArgs: DevServerConfiguration = { port: options.develop.port, + host: options.develop.host, client: { logging: "none", overlay: { errors: true, warnings: false, }, - webSocketURL: options.develop.webSocketURL ? options.develop.webSocketURL : `ws://localhost:${options.develop.port}/ws`, + webSocketURL: options.develop.webSocketURL + ? options.develop.webSocketURL + : `ws://${options.develop.host}:${options.develop.port}/ws`, }, open: false, onListening: options.develop.open @@ -70,7 +74,7 @@ export async function develop({ } openBrowser( - `http://localhost:${options.develop.port}${ + `http://${options.develop.host}:${options.develop.port}${ options.path ? options.path : "" }` ) @@ -85,16 +89,18 @@ export async function develop({ disableDotRule: true, }, hot: true, - allowedHosts: options.develop.allowedHosts ? options.develop.allowedHosts : 'auto', + allowedHosts: options.develop.allowedHosts + ? options.develop.allowedHosts + : "auto", } const server = new WebpackDevDerver(devServerArgs, compiler) const runServer = async () => { logger.info( - `Started development server on http://localhost:${options.develop.port}${ - options.path ? options.path : "" - }` + `Started development server on http://${options.develop.host}:${ + options.develop.port + }${options.path ? options.path : ""}` ) await server.start() diff --git a/packages/admin-ui/src/node/types.ts b/packages/admin-ui/src/node/types.ts index b090398b0a..5f23123280 100644 --- a/packages/admin-ui/src/node/types.ts +++ b/packages/admin-ui/src/node/types.ts @@ -17,6 +17,12 @@ export type DevelopOptions = { * @default true */ open?: boolean + /** + * The host the development server should run on. + * + * @default "localhost" + */ + host?: string /** * The port the development server should run on. * @default 7001 @@ -40,7 +46,7 @@ export type DevelopOptions = { /** * Specifying URL to web socket server */ - webSocketURL?: string | WebSocketURL |undefined + webSocketURL?: string | WebSocketURL | undefined } export type AdminOptions = { diff --git a/packages/medusa/src/commands/develop.js b/packages/medusa/src/commands/develop.js index cbf30b19c7..77bc14292b 100644 --- a/packages/medusa/src/commands/develop.js +++ b/packages/medusa/src/commands/develop.js @@ -76,9 +76,7 @@ export default async function ({ port, directory }) { const { cli, binExists } = resolveAdminCLI() if (binExists) { - const backendUrl = `http://localhost:${port}` - - const adminChild = fork(cli, [`develop`, "--backend", `${backendUrl}`], { + const adminChild = fork(cli, [`develop`], { cwd: directory, env: process.env, stdio: ["pipe", process.stdout, process.stderr, "ipc"],