From d08496cd94efce04920018e79b792b8e51864e5a Mon Sep 17 00:00:00 2001 From: Jack Palmer Date: Wed, 18 May 2022 15:18:27 +0200 Subject: [PATCH 1/4] feat: Add console warning when app.baseUrl and backend.baseUrl are identical Signed-off-by: Jack Palmer --- .../cli/src/commands/start/startFrontend.ts | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/start/startFrontend.ts b/packages/cli/src/commands/start/startFrontend.ts index e5500c310b..4c08ff6d5f 100644 --- a/packages/cli/src/commands/start/startFrontend.ts +++ b/packages/cli/src/commands/start/startFrontend.ts @@ -62,14 +62,30 @@ export async function startFrontend(options: StartAppOptions) { } const { name } = await fs.readJson(paths.resolveTarget('package.json')); + const config = await loadCliConfig({ + args: options.configPaths, + fromPackage: name, + withFilteredKeys: true, + }); + + const appBaseUrl = config.frontendConfig.getString('app.baseUrl'); + const backendBaseUrl = config.frontendConfig.getString('backend.baseUrl'); + if (appBaseUrl === backendBaseUrl) { + console.log( + chalk.yellow( + `⚠️ Conflict between app baseUrl and backend baseUrl: + + app.baseUrl: ${appBaseUrl} + backend.baseUrl: ${appBaseUrl} +`, + ), + ); + } + const waitForExit = await serveBundle({ entry: options.entry, checksEnabled: options.checksEnabled, - ...(await loadCliConfig({ - args: options.configPaths, - fromPackage: name, - withFilteredKeys: true, - })), + ...config, }); await waitForExit(); From db27a98afa3246f9e3fecfbb3d0cf59a814767a5 Mon Sep 17 00:00:00 2001 From: Jack Palmer Date: Wed, 18 May 2022 15:25:51 +0200 Subject: [PATCH 2/4] changeset: added Signed-off-by: Jack Palmer --- .changeset/fuzzy-colts-enjoy.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fuzzy-colts-enjoy.md diff --git a/.changeset/fuzzy-colts-enjoy.md b/.changeset/fuzzy-colts-enjoy.md new file mode 100644 index 0000000000..5ebccd59a3 --- /dev/null +++ b/.changeset/fuzzy-colts-enjoy.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': minor +--- + +Added console warning to frontend start when the `app.baseUrl` and `backend.baseUrl` are identical From 6de866ea74a56183c64b270f8d48c1be1d86ac9e Mon Sep 17 00:00:00 2001 From: Jack Palmer Date: Thu, 19 May 2022 09:25:41 +0100 Subject: [PATCH 3/4] fix: Change changeset to patch Signed-off-by: Jack Palmer --- .changeset/{fuzzy-colts-enjoy.md => shiny-clocks-joke.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .changeset/{fuzzy-colts-enjoy.md => shiny-clocks-joke.md} (81%) diff --git a/.changeset/fuzzy-colts-enjoy.md b/.changeset/shiny-clocks-joke.md similarity index 81% rename from .changeset/fuzzy-colts-enjoy.md rename to .changeset/shiny-clocks-joke.md index 5ebccd59a3..3784cb1b7d 100644 --- a/.changeset/fuzzy-colts-enjoy.md +++ b/.changeset/shiny-clocks-joke.md @@ -1,5 +1,5 @@ --- -'@backstage/cli': minor +'@backstage/cli': patch --- Added console warning to frontend start when the `app.baseUrl` and `backend.baseUrl` are identical From 76f490ee0f6e57414ad12fae185a470d12899a5b Mon Sep 17 00:00:00 2001 From: Jack Palmer Date: Thu, 19 May 2022 11:17:17 +0100 Subject: [PATCH 4/4] fix: Add resolution steps to warning Signed-off-by: Jack Palmer --- packages/cli/src/commands/start/startFrontend.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/start/startFrontend.ts b/packages/cli/src/commands/start/startFrontend.ts index 4c08ff6d5f..f6923632c8 100644 --- a/packages/cli/src/commands/start/startFrontend.ts +++ b/packages/cli/src/commands/start/startFrontend.ts @@ -44,7 +44,7 @@ export async function startFrontend(options: StartAppOptions) { if (problemPackages.length > 1) { console.log( chalk.yellow( - `⚠️ Some of the following packages may be outdated or have duplicate installations: + `⚠️ Some of the following packages may be outdated or have duplicate installations: ${uniq(problemPackages).join(', ')} `, @@ -52,7 +52,7 @@ export async function startFrontend(options: StartAppOptions) { ); console.log( chalk.yellow( - `⚠️ This can be resolved using the following command: + `⚠️ This can be resolved using the following command: yarn backstage-cli versions:check --fix `, @@ -73,10 +73,14 @@ export async function startFrontend(options: StartAppOptions) { if (appBaseUrl === backendBaseUrl) { console.log( chalk.yellow( - `⚠️ Conflict between app baseUrl and backend baseUrl: + `⚠️ Conflict between app baseUrl and backend baseUrl: - app.baseUrl: ${appBaseUrl} - backend.baseUrl: ${appBaseUrl} + app.baseUrl: ${appBaseUrl} + backend.baseUrl: ${appBaseUrl} + + Must have unique hostname and/or ports. + + This can be resolved by changing app.baseUrl and backend.baseUrl to point to their respective local development ports. `, ), );