feat(cli): Support specifying listen host/port for frontend

This commit is contained in:
Joel Low
2020-11-18 14:11:15 +08:00
parent 74b9561a2b
commit 9023404510
2 changed files with 12 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Support specifying listen host/port for frontend
+7 -2
View File
@@ -25,7 +25,12 @@ import { resolveBundlingPaths } from './paths';
export async function serveBundle(options: ServeOptions) {
const url = resolveBaseUrl(options.config);
const port = Number(url.port) || (url.protocol === 'https:' ? 443 : 80);
const host =
options.config.getOptionalString('app.listen.host') || url.hostname;
const port =
options.config.getOptionalNumber('app.listen.port') ||
Number(url.port) ||
(url.protocol === 'https:' ? 443 : 80);
const paths = resolveBundlingPaths(options);
const pkgPath = paths.targetPackageJson;
@@ -50,7 +55,7 @@ export async function serveBundle(options: ServeOptions) {
clientLogLevel: 'warning',
stats: 'errors-warnings',
https: url.protocol === 'https:',
host: url.hostname,
host,
port,
proxy: pkg.proxy,
});