diff options
Diffstat (limited to 'packages/web-util/src/serve.ts')
-rw-r--r-- | packages/web-util/src/serve.ts | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/web-util/src/serve.ts b/packages/web-util/src/serve.ts index 3d2744bb9..1daea15bf 100644 --- a/packages/web-util/src/serve.ts +++ b/packages/web-util/src/serve.ts @@ -29,6 +29,7 @@ export async function serve(opts: { folder: string; port: number; source?: string; + tls?: boolean; examplesLocationJs?: string; examplesLocationCss?: string; onSourceUpdate?: () => Promise<void>; @@ -39,9 +40,14 @@ export async function serve(opts: { const httpServer = http.createServer(app); const httpPort = opts.port; - const httpsServer = https.createServer(httpServerOptions, app); - const httpsPort = opts.port + 1; - const servers = [httpServer, httpsServer]; + let httpsServer: typeof httpServer | undefined; + let httpsPort: number | undefined; + const servers = [httpServer]; + if (opts.tls) { + httpsServer = https.createServer(httpServerOptions, app); + httpsPort = opts.port + 1; + servers.push(httpsServer) + } logger.info(`Dev server. Endpoints:`); logger.info(` ${PATHS.APP}: where root application can be tested`); @@ -120,6 +126,8 @@ export async function serve(opts: { logger.info(`Serving ${opts.folder} on ${httpPort}: plain HTTP`); httpServer.listen(httpPort); - logger.info(`Serving ${opts.folder} on ${httpsPort}: HTTP + TLS`); - httpsServer.listen(httpsPort); + if (httpsServer !== undefined) { + logger.info(`Serving ${opts.folder} on ${httpsPort}: HTTP + TLS`); + httpsServer.listen(httpsPort); + } } |