**What** Fix of https://github.com/medusajs/medusa/issues/4904 **Fixes** Admin run development server with hostname shown Invalid Request Header **How** Added webpack-dev-server config [allowedHosts](https://webpack.js.org/configuration/dev-server/#devserverallowedhosts) and [webSocketUrl](https://webpack.js.org/configuration/dev-server/#websocketurl) in admin develop options to change allowlist services hostname and Web Socket Url **Testing** Edit medusa-config.js with hostname in admin plugin develop options ``` const plugins = [ // ... { resolve: "@medusajs/admin", /** @type {import('@medusajs/admin').PluginOptions} */ options: { develop: { allowedHosts: [ 'host.com', 'subdomain.host.com', 'subdomain2.host.com', 'host2.com', ], webSocketURL: 'wss://host.com/ws' }, }, }, ] ``` Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
35 lines
859 B
TypeScript
35 lines
859 B
TypeScript
import { AdminOptions, develop as adminDevelop } from "@medusajs/admin-ui"
|
|
import { getPluginPaths, loadConfig } from "../utils"
|
|
|
|
type DevelopArgs = AdminOptions & {
|
|
port: number
|
|
}
|
|
|
|
export default async function develop({ backend, path, port }: DevelopArgs) {
|
|
const config = loadConfig(true)
|
|
|
|
if (!config) {
|
|
// @medusajs/admin is not part of the projects plugins
|
|
// so we return early
|
|
return
|
|
}
|
|
|
|
const plugins = await getPluginPaths()
|
|
|
|
await adminDevelop({
|
|
appDir: process.cwd(),
|
|
buildDir: config.outDir,
|
|
plugins,
|
|
options: {
|
|
backend: backend || config.backend,
|
|
path: path || config.path,
|
|
develop: {
|
|
port: port || config.develop.port,
|
|
open: config.develop.open,
|
|
allowedHosts: config.develop.allowedHosts,
|
|
webSocketURL: config.develop.webSocketURL,
|
|
},
|
|
},
|
|
})
|
|
}
|