From 9c1e0de3e6d42a7a5d0bb62ac9af1be47f53b6f9 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 9 Feb 2021 13:38:33 +0100 Subject: [PATCH 1/3] app-backend: more docs for options --- plugins/app-backend/src/service/router.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/app-backend/src/service/router.ts b/plugins/app-backend/src/service/router.ts index 65cbddaae6..3a22a7a6b0 100644 --- a/plugins/app-backend/src/service/router.ts +++ b/plugins/app-backend/src/service/router.ts @@ -26,7 +26,22 @@ import fs from 'fs-extra'; export interface RouterOptions { config: Config; logger: Logger; + + /** + * The name of the app package that content should be served from. The same app package should be + * added as a dependency to the backend package in order for it to be accessible at runtime. + * + * In a typical setup with a single app package this would be set to 'app'. + */ appPackageName: string; + + /** + * A request handler to handle requests for static content that are not present in the app bundle. + * + * This can be used to avoid issues with clients on older deployment versions trying to access lazy + * loaded content that is no longer present. Typically the requests would fall back to a long-term + * object store where all recently deployed versions of the app are present. + */ staticFallbackHandler?: express.Handler; } From f807a21dd3d169efde0faa181be218b3e5e3d241 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 9 Feb 2021 13:38:58 +0100 Subject: [PATCH 2/3] app-backend: add disableConfigInjection option, which disables config injection --- plugins/app-backend/src/service/router.ts | 25 +++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/plugins/app-backend/src/service/router.ts b/plugins/app-backend/src/service/router.ts index 3a22a7a6b0..4379fcccb9 100644 --- a/plugins/app-backend/src/service/router.ts +++ b/plugins/app-backend/src/service/router.ts @@ -43,6 +43,17 @@ export interface RouterOptions { * object store where all recently deployed versions of the app are present. */ staticFallbackHandler?: express.Handler; + + /** + * Disables the configuration injection. This can be useful if you're running in an environment + * with a read-only filesystem, or for some other reason don't want configuration to be injected. + * + * Note that this will cause the configuration used when building the app bundle to be used, unless + * a separate configuration loading strategy is set up. + * + * This also disables configuration injection though `APP_CONFIG_` environment variables. + */ + disableConfigInjection?: boolean; } export async function createRouter( @@ -63,13 +74,15 @@ export async function createRouter( logger.info(`Serving static app content from ${appDistDir}`); - const appConfigs = await readConfigs({ - config, - appDistDir, - env: process.env, - }); + if (!options.disableConfigInjection) { + const appConfigs = await readConfigs({ + config, + appDistDir, + env: process.env, + }); - await injectConfig({ appConfigs, logger, staticDir }); + await injectConfig({ appConfigs, logger, staticDir }); + } const router = Router(); From 727f0deeca4b18fedb5f4eb1516d9f283921198a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 9 Feb 2021 13:39:44 +0100 Subject: [PATCH 3/3] add changeset --- .changeset/empty-cooks-laugh.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/empty-cooks-laugh.md diff --git a/.changeset/empty-cooks-laugh.md b/.changeset/empty-cooks-laugh.md new file mode 100644 index 0000000000..8f509f08cd --- /dev/null +++ b/.changeset/empty-cooks-laugh.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-app-backend': patch +--- + +Added a new `disableConfigInjection` option, which can be used to disable the configuration injection in environments where it can't be used.