@@ -636,20 +636,20 @@ class Server {
636
636
let networkUrlIPv4 ;
637
637
let networkUrlIPv6 ;
638
638
639
- if ( this . hostname ) {
640
- if ( this . hostname === 'localhost' ) {
639
+ if ( this . options . host ) {
640
+ if ( this . options . host === 'localhost' ) {
641
641
localhost = prettyPrintUrl ( 'localhost' ) ;
642
642
} else {
643
643
let isIP ;
644
644
645
645
try {
646
- isIP = ipaddr . parse ( this . hostname ) ;
646
+ isIP = ipaddr . parse ( this . options . host ) ;
647
647
} catch ( error ) {
648
648
// Ignore
649
649
}
650
650
651
651
if ( ! isIP ) {
652
- server = prettyPrintUrl ( this . hostname ) ;
652
+ server = prettyPrintUrl ( this . options . host ) ;
653
653
}
654
654
}
655
655
}
@@ -744,21 +744,22 @@ class Server {
744
744
}
745
745
746
746
if ( this . options . open ) {
747
- const openTarget = prettyPrintUrl ( this . hostname || 'localhost' ) ;
747
+ const openTarget = prettyPrintUrl ( this . options . host || 'localhost' ) ;
748
748
749
749
runOpen ( openTarget , this . options . open , this . logger ) ;
750
750
}
751
751
}
752
752
753
753
listen ( port , hostname , fn ) {
754
754
if ( hostname === 'local-ip' ) {
755
- this . hostname = internalIp . v4 . sync ( ) || internalIp . v6 . sync ( ) || '0.0.0.0' ;
755
+ this . options . host =
756
+ internalIp . v4 . sync ( ) || internalIp . v6 . sync ( ) || '0.0.0.0' ;
756
757
} else if ( hostname === 'local-ipv4' ) {
757
- this . hostname = internalIp . v4 . sync ( ) || '0.0.0.0' ;
758
+ this . options . host = internalIp . v4 . sync ( ) || '0.0.0.0' ;
758
759
} else if ( hostname === 'local-ipv6' ) {
759
- this . hostname = internalIp . v6 . sync ( ) || '::' ;
760
+ this . options . host = internalIp . v6 . sync ( ) || '::' ;
760
761
} else {
761
- this . hostname = hostname ;
762
+ this . options . host = hostname ;
762
763
}
763
764
764
765
if ( typeof port !== 'undefined' && port !== this . options . port ) {
@@ -773,7 +774,7 @@ class Server {
773
774
. then ( ( port ) => {
774
775
this . options . port = port ;
775
776
776
- return this . server . listen ( port , this . hostname , ( error ) => {
777
+ return this . server . listen ( port , this . options . host , ( error ) => {
777
778
if ( this . options . hot || this . options . liveReload ) {
778
779
this . createSocketServer ( ) ;
779
780
}
@@ -903,12 +904,12 @@ class Server {
903
904
// these are removed from the hostname in url.parse(),
904
905
// so we have the pure IPv6-address in hostname.
905
906
// always allow localhost host, for convenience (hostname === 'localhost')
906
- // allow hostname of listening address (hostname === this.hostname )
907
+ // allow hostname of listening address (hostname === this.options.host )
907
908
const isValidHostname =
908
909
ipaddr . IPv4 . isValid ( hostname ) ||
909
910
ipaddr . IPv6 . isValid ( hostname ) ||
910
911
hostname === 'localhost' ||
911
- hostname === this . hostname ;
912
+ hostname === this . options . host ;
912
913
913
914
if ( isValidHostname ) {
914
915
return true ;
0 commit comments