diff --git a/.changeset/fast-paws-press.md b/.changeset/fast-paws-press.md new file mode 100644 index 0000000000..8ddb0bc49e --- /dev/null +++ b/.changeset/fast-paws-press.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Added support for custom certificate for webpack dev server. diff --git a/app-config.yaml b/app-config.yaml index 32b53da236..7c93d9cbd2 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -7,7 +7,6 @@ app: # applicationId: qwerty # site: # datadoghq.eu default = datadoghq.com # env: # optional - support: url: https://github.com/backstage/backstage/issues # Used by common ErrorPage items: # Used by common SupportButton component diff --git a/packages/cli/package.json b/packages/cli/package.json index 14482fc95b..5514b881e1 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -248,6 +248,32 @@ "description": "The port that the frontend should be bound to. Only used for local development." } } + }, + "https": { + "type": "object", + "description": "Only used for local development. The https object is passed to webpack in order to enable using https on localhost.", + "properties": { + "certificate": { + "type": "object", + "description": "Parent object containing certificate and the private key", + "required": [ + "key", + "cert" + ], + "properties": { + "key": { + "type": "string", + "visibility": "secret", + "description": "Https Certificate private key. Use $file to load in a file" + }, + "cert": { + "type": "string", + "visibility": "secret", + "description": "Https Certificate. Use $file to load in a file" + } + } + } + } } } } diff --git a/packages/cli/src/lib/bundler/server.ts b/packages/cli/src/lib/bundler/server.ts index d573f80e27..d3f1e8da75 100644 --- a/packages/cli/src/lib/bundler/server.ts +++ b/packages/cli/src/lib/bundler/server.ts @@ -40,6 +40,7 @@ export async function serveBundle(options: ServeOptions) { isDev: true, baseUrl: url, }); + const compiler = webpack(config); const server = new WebpackDevServer( @@ -60,7 +61,15 @@ export async function serveBundle(options: ServeOptions) { // See https://github.com/facebookincubator/create-react-app/issues/387. disableDotRule: true, }, - https: url.protocol === 'https:', + https: + url.protocol === 'https:' + ? { + cert: options.backendConfig.getString( + 'app.https.certificate.cert', + ), + key: options.backendConfig.getString('app.https.certificate.key'), + } + : false, host, port, proxy: pkg.proxy, diff --git a/packages/cli/src/lib/bundler/types.ts b/packages/cli/src/lib/bundler/types.ts index 4d6d2e5c9e..68260735f9 100644 --- a/packages/cli/src/lib/bundler/types.ts +++ b/packages/cli/src/lib/bundler/types.ts @@ -31,6 +31,7 @@ export type ServeOptions = BundlingPathsOptions & { checksEnabled: boolean; frontendConfig: Config; frontendAppConfigs: AppConfig[]; + backendConfig: Config; }; export type BuildOptions = BundlingPathsOptions & { diff --git a/packages/cli/src/lib/config.ts b/packages/cli/src/lib/config.ts index e7ceeadf08..994714a3ce 100644 --- a/packages/cli/src/lib/config.ts +++ b/packages/cli/src/lib/config.ts @@ -96,11 +96,15 @@ export async function loadCliConfig(options: Options) { }); const frontendConfig = ConfigReader.fromConfigs(frontendAppConfigs); + const backendAppConfigs = schema.process(appConfigs); + const backendConfig = ConfigReader.fromConfigs(backendAppConfigs); + return { schema, appConfigs, frontendConfig, frontendAppConfigs, + backendConfig, }; } catch (error) { const maybeSchemaError = error as Error & { messages?: string[] };