@@ -16,6 +16,7 @@ import { debug, logger } from '../utils/logger'
1616import { resolveCertificate } from './cert'
1717import { detectIsolatedEnvironment , isWsl } from './environment'
1818import { resolvePortlessURLs } from './portless'
19+ import { resolveStackblitzURL } from './stackblitz'
1920import { startTunnel } from './tunnel'
2021
2122export interface ListenOptions {
@@ -164,6 +165,7 @@ export async function listen(handler: RequestListener, options: ListenOptions =
164165 const portless = resolvePortlessURLs ( )
165166 const portlessURL = portless . url && portless . url + baseURL
166167 const portlessShareURL = portless . shareURL && portless . shareURL + baseURL
168+ const stackblitzURL = resolveStackblitzURL ( )
167169
168170 function getURLs ( ) : ListenURL [ ] {
169171 const urls : ListenURL [ ] = [ ]
@@ -173,6 +175,9 @@ export async function listen(handler: RequestListener, options: ListenOptions =
173175 for ( const portlessURL of portless . all ) {
174176 urls . push ( { url : portlessURL + baseURL , type : 'public' } )
175177 }
178+ if ( stackblitzURL ) {
179+ urls . push ( { url : stackblitzURL , type : 'public' } )
180+ }
176181 if ( anyHost ) {
177182 urls . push ( { url : formatURL ( 'localhost' ) , type : 'local' } )
178183 for ( const address of getNetworkAddresses ( ) ) {
@@ -185,11 +190,14 @@ export async function listen(handler: RequestListener, options: ListenOptions =
185190 return urls
186191 }
187192
188- const publicURL = options . publicURL || tunnel ?. url || portlessShareURL || portlessURL
193+ // The StackBlitz URL points at the editor rather than at a host another
194+ // device can open, so it is not a QR code candidate.
195+ const shareableURL = options . publicURL || tunnel ?. url || portlessShareURL || portlessURL
196+ const publicURL = shareableURL || stackblitzURL
189197
190198 const qrURL = options . qr === false
191199 ? undefined
192- : publicURL
200+ : shareableURL
193201 || getURLs ( ) . find ( ( { type } ) => type === 'network' ) ?. url
194202 || ( options . qr ? url : undefined )
195203
@@ -203,7 +211,7 @@ export async function listen(handler: RequestListener, options: ListenOptions =
203211 for ( const { url : displayURL , type } of urls ) {
204212 lines . push ( line ( labelColors [ type ] , labels [ type ] , colors . cyan ( displayURL ) , qr && displayURL === qrURL ) )
205213 }
206- if ( ! anyHost && ! tunnel && ! portless . url ) {
214+ if ( ! anyHost && ! tunnel && ! portless . url && ! stackblitzURL ) {
207215 const isolated = LOOPBACK_HOSTS . has ( hostname ) ? detectIsolatedEnvironment ( ) : undefined
208216 const hint = isolated
209217 ? `use ${ colors . white ( '--host' ) } to reach this server from outside ${ isolated } `
0 commit comments