Skip to content

Commit

Permalink
fix(plugin-vite): handle ipv6 address
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcherGu committed Jan 30, 2023
1 parent 1754a05 commit 8457ea1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/plugin-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ export function VitePluginDoubleshot(userConfig: Partial<VitePluginDoubleshotCon
},
configureServer(server) {
server?.httpServer?.on('listening', async () => {
if (server.httpServer) {
const { address, port } = server.httpServer.address() as AddressInfo
userConfig.rendererUrl = `http://${address}:${port}`
if (server.httpServer && !userConfig.rendererUrl) {
const { address, port, family } = server.httpServer.address() as AddressInfo
if (family === 'IPv6')
userConfig.rendererUrl = `http://[${address}]:${port}`

else
userConfig.rendererUrl = `http://${address}:${port}`
}

await dev(userConfig)
Expand Down

0 comments on commit 8457ea1

Please sign in to comment.