fix(admin-ui): Admin UI: Invalid Request Header (#5548)

**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>
This commit is contained in:
Rick Lam
2023-11-09 12:32:27 +00:00
committed by GitHub
parent 91615f9c45
commit b4e8adfcf9
6 changed files with 33 additions and 0 deletions

View File

@@ -26,6 +26,8 @@ export default async function develop({ backend, path, port }: DevelopArgs) {
develop: {
port: port || config.develop.port,
open: config.develop.open,
allowedHosts: config.develop.allowedHosts,
webSocketURL: config.develop.webSocketURL,
},
},
})

View File

@@ -27,6 +27,7 @@ export const loadConfig = (isDev?: boolean): PluginOptions | null => {
develop: {
open: true,
port: 7001,
allowedHosts: 'auto',
},
}
@@ -50,6 +51,8 @@ export const loadConfig = (isDev?: boolean): PluginOptions | null => {
develop: {
open: options.develop?.open ?? config.develop.open,
port: options.develop?.port ?? config.develop.port,
allowedHosts: options.develop?.allowedHosts ?? config.develop.allowedHosts,
webSocketURL: options.develop?.webSocketURL ?? config.develop.webSocketURL,
},
}
}