File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -40,8 +40,10 @@ const addEntry = ({
40
40
} ,
41
41
configureServer ( server ) {
42
42
server . httpServer ?. once ?.( 'listening' , ( ) => {
43
- const { port } = server . config . server ;
44
- fetch ( `http://localhost:${ port } ${ devEntryPath } ` ) . catch ( ( e ) => { } ) ;
43
+ const { port, host : hostConfig } = server . config . server ;
44
+ const host =
45
+ typeof hostConfig === 'string' && hostConfig !== '0.0.0.0' ? hostConfig : 'localhost' ;
46
+ fetch ( `http://${ host } :${ port } ${ devEntryPath } ` ) . catch ( ( e ) => { } ) ;
45
47
} ) ;
46
48
server . middlewares . use ( ( req , res , next ) => {
47
49
if ( ! fileName ) {
Original file line number Diff line number Diff line change @@ -56,8 +56,12 @@ export default function (): Plugin {
56
56
if ( id . includes ( getHostAutoInitPath ( ) ) ) {
57
57
const options = getNormalizeModuleFederationOptions ( ) ;
58
58
if ( _command === 'serve' ) {
59
+ const host =
60
+ typeof viteConfig . server ?. host === 'string' && viteConfig . server . host !== '0.0.0.0'
61
+ ? viteConfig . server . host
62
+ : 'localhost' ;
59
63
return `
60
- const {init} = await import("//localhost :${ viteConfig . server ?. port } ${ viteConfig . base + options . filename } ")
64
+ const {init} = await import("//${ host } :${ viteConfig . server ?. port } ${ viteConfig . base + options . filename } ")
61
65
init()
62
66
` ;
63
67
}
You can’t perform that action at this time.
0 commit comments