@@ -632,7 +632,10 @@ function printInfo(
632
632
tunnelUrl ?: string ,
633
633
publicIp ?: string ,
634
634
) {
635
- const baseUrl = port && `http://localhost:${ bold ( port + ( base ?. slice ( 0 , - 1 ) || '' ) ) } `
635
+ if ( base && ( ! base . startsWith ( '/' ) || ! base . endsWith ( '/' ) ) ) {
636
+ console . error ( 'Base URL must start and end with a slash "/"' )
637
+ process . exit ( 1 )
638
+ }
636
639
637
640
console . log ( )
638
641
console . log ( )
@@ -646,7 +649,10 @@ function printInfo(
646
649
console . log ( dim ( ' css engine ' ) + blue ( 'unocss' ) )
647
650
console . log ( dim ( ' entry ' ) + dim ( path . normalize ( path . dirname ( options . entry ) ) + path . sep ) + path . basename ( options . entry ) )
648
651
649
- if ( baseUrl ) {
652
+ if ( port ) {
653
+ const baseText = base ?. slice ( 0 , - 1 ) || ''
654
+ const portAndBase = port + baseText
655
+ const baseUrl = `http://localhost:${ bold ( portAndBase ) } `
650
656
const query = remote ? `?password=${ remote } ` : ''
651
657
const presenterPath = `${ options . data . config . routerMode === 'hash' ? '/#/' : '/' } presenter/${ query } `
652
658
const entryPath = `${ options . data . config . routerMode === 'hash' ? '/#/' : '/' } entry${ query } /`
@@ -670,17 +676,17 @@ function printInfo(
670
676
. forEach ( v => ( v || [ ] )
671
677
. filter ( details => String ( details . family ) . slice ( - 1 ) === '4' && ! details . address . includes ( '127.0.0.1' ) )
672
678
. forEach ( ( { address } ) => {
673
- lastRemoteUrl = `http://${ address } :${ port } ${ entryPath } `
679
+ lastRemoteUrl = `http://${ address } :${ portAndBase } ${ entryPath } `
674
680
console . log ( `${ dim ( ' remote control ' ) } > ${ blue ( lastRemoteUrl ) } ` )
675
681
} ) )
676
682
677
683
if ( publicIp ) {
678
- lastRemoteUrl = `http://${ publicIp } :${ port } ${ entryPath } `
684
+ lastRemoteUrl = `http://${ publicIp } :${ portAndBase } ${ entryPath } `
679
685
console . log ( `${ dim ( ' remote control ' ) } > ${ blue ( lastRemoteUrl ) } ` )
680
686
}
681
687
682
688
if ( tunnelUrl ) {
683
- lastRemoteUrl = `${ tunnelUrl } ${ entryPath } `
689
+ lastRemoteUrl = `${ tunnelUrl } ${ baseText } ${ entryPath } `
684
690
console . log ( `${ dim ( ' remote via tunnel' ) } > ${ yellow ( lastRemoteUrl ) } ` )
685
691
}
686
692
}
0 commit comments