Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/core/src/client/standalone/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export default defineConfig({
: viteDevServer.config.server.host || 'localhost'
const { middleware } = await createDevToolsMiddleware({
cwd: viteDevServer.config.root,
hostWebSocket: host,
websocket: {
host,
https: false,
},
context,
})
viteDevServer.middlewares.use(DEVTOOLS_MOUNT_PATH_NO_TRAILING_SLASH, middleware)
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/node/cli-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export async function start(options: StartOptions) {
})
const { h3 } = await createDevToolsMiddleware({
cwd: devtools.config.root,
hostWebSocket: host,
websocket: {
host,
https: false,
},
context: devtools.context,
})

Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/node/plugins/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export function DevToolsServer(): Plugin {

const { middleware } = await createDevToolsMiddleware({
cwd: viteDevServer.config.root,
hostWebSocket: host,
websocket: {
host,
},
context,
})
viteDevServer.middlewares.use(DEVTOOLS_MOUNT_PATH, middleware)
Expand Down
13 changes: 8 additions & 5 deletions packages/core/src/node/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ const debugInvoked = createDebug('vite:devtools:rpc:invoked')

export interface CreateWsServerOptions {
cwd: string
portWebSocket?: number
hostWebSocket: string
websocket: {
port?: number
host: string
https?: DevToolsNodeContext['viteConfig']['server']['https'] | false
}
base?: string
context: DevToolsNodeContext
}
Expand All @@ -26,9 +29,9 @@ const ANONYMOUS_SCOPE = 'vite:anonymous:'

export async function createWsServer(options: CreateWsServerOptions) {
const rpcHost = options.context.rpc as unknown as RpcFunctionsHost
const host = options.hostWebSocket ?? 'localhost'
const https = options.context.viteConfig.server.https
const port = options.portWebSocket ?? await getPort({ port: 7812, host, random: true })!
const host = options.websocket.host
const https = options.websocket.https === false ? undefined : (options.websocket.https ?? options.context.viteConfig.server.https)
const port = options.websocket.port ?? await getPort({ port: 7812, host, random: true })!

const wsClients = new Set<WebSocket>()

Expand Down
Loading