File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -101,17 +101,17 @@ export class PrinterService {
101101
102102 let url = publicUrl ;
103103
104- if ( [ publicUrl , storageUrl ] . some ( ( url ) => url . includes ( "localhost" ) ) ) {
105- // Switch client URL from `localhost` to `host.docker.internal` in development
104+ if ( [ publicUrl , storageUrl ] . some ( ( url ) => / h t t p s ? : \/ \/ l o c a l h o s t ( : \d + ) ? / . test ( url ) ) ) {
105+ // Switch client URL from `http[s]:// localhost[:port] ` to `http[s]:// host.docker.internal[:port] ` in development
106106 // This is required because the browser is running in a container and the client is running on the host machine.
107- url = url . replace ( " localhost" , "host.docker.internal" ) ;
108-
107+ url = url . replace ( / l o c a l h o s t ( : \d + ) ? / , "host.docker.internal" ) ;
108+
109109 await page . setRequestInterception ( true ) ;
110110
111111 // Intercept requests of `localhost` to `host.docker.internal` in development
112112 page . on ( "request" , ( request ) => {
113113 if ( request . url ( ) . startsWith ( storageUrl ) ) {
114- const modifiedUrl = request . url ( ) . replace ( " localhost" , ` host.docker.internal` ) ;
114+ const modifiedUrl = request . url ( ) . replace ( / l o c a l h o s t ( : \d + ) ? / , " host.docker.internal" ) ;
115115
116116 void request . continue ( { url : modifiedUrl } ) ;
117117 } else {
You can’t perform that action at this time.
0 commit comments