Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
3 changes: 3 additions & 0 deletions packages/admin-ui/src/node/actions/develop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export async function develop({
port: 7001,
logLevel: "error",
stats: "normal",
allowedHosts: 'auto',
},
},
}: DevelopArgs) {
Expand Down Expand Up @@ -59,6 +60,7 @@ export async function develop({
errors: true,
warnings: false,
},
webSocketURL: options.develop.webSocketURL ? options.develop.webSocketURL : `ws://localhost:${options.develop.port}/ws`,
},
open: false,
onListening: options.develop.open
Expand All @@ -83,6 +85,7 @@ export async function develop({
disableDotRule: true,
},
hot: true,
allowedHosts: options.develop.allowedHosts ? options.develop.allowedHosts : 'auto',
}

const server = new WebpackDevDerver(devServerArgs, compiler)
Expand Down
18 changes: 18 additions & 0 deletions packages/admin-ui/src/node/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import type { Configuration } from "webpack"

type WebSocketURL = {
hostname?: string | undefined
password?: string | undefined
pathname?: string | undefined
port?: string | number | undefined
protocol?: string | undefined
username?: string | undefined
}

export type DevelopOptions = {
/**
* Determines whether the development server should open the admin dashboard
Expand All @@ -23,6 +32,15 @@ export type DevelopOptions = {
* @default "normal"
*/
stats?: "normal" | "debug"
/**
* The development server allowed hosts.
* @default "auto"
*/
allowedHosts?: "auto" | "all" | string[]
/**
* Specifying URL to web socket server
*/
webSocketURL?: string | WebSocketURL |undefined
}

export type AdminOptions = {
Expand Down
1 change: 1 addition & 0 deletions packages/admin-ui/webpack.config.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const getDevServerConfig = () => {
onListening: function () {
openBrowser(`http://localhost:7001`)
},
allowedHosts: 'auto',
} as Configuration,
},
}
Expand Down
2 changes: 2 additions & 0 deletions packages/admin/src/commands/develop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
})
Expand Down
3 changes: 3 additions & 0 deletions packages/admin/src/utils/load-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const loadConfig = (isDev?: boolean): PluginOptions | null => {
develop: {
open: true,
port: 7001,
allowedHosts: 'auto',
},
}

Expand All @@ -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,
},
}
}
Expand Down