From 9c138d7fede98bd061034ef0832b4578747223df Mon Sep 17 00:00:00 2001 From: case-E Date: Mon, 12 Aug 2024 20:00:57 +0530 Subject: [PATCH 1/5] added an env variable after rebasing from main --- waspc/packages/deploy/src/providers/fly/deploy/deploy.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts b/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts index 4dd3713ac3..609e73b45d 100644 --- a/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts +++ b/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts @@ -103,8 +103,11 @@ async function deployClient(deploymentInfo: DeploymentInfo, { bui copyProjectClientTomlLocally(deploymentInfo.tomlFilePaths); waspSays('Building web client for production...'); + waspSays('If you configured a custom domain for the server, please run the command with an env variable: REACT_APP_API_URL=https://serverUrl.com wasp deploy fly deploy'); + + const serverUrl = process.env.REACT_APP_API_URL || deploymentInfo.serverUrl; await $`npm install`; - await $`REACT_APP_API_URL=${deploymentInfo.serverUrl} npm run build`; + await $`REACT_APP_API_URL=${serverUrl} npm run build`; // Creates the necessary Dockerfile for deploying static websites to Fly.io. // Adds dummy .dockerignore to supress CLI question. From 632b7f2cb673b7e026fa2cdcbb0be57de02eee49 Mon Sep 17 00:00:00 2001 From: case-E Date: Mon, 12 Aug 2024 22:31:38 +0530 Subject: [PATCH 2/5] Added a helper fn to stripTrailingSlash --- waspc/packages/deploy/src/providers/fly/deploy/deploy.ts | 3 ++- waspc/packages/deploy/src/providers/fly/helpers/helpers.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts b/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts index 609e73b45d..6306cb990a 100644 --- a/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts +++ b/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts @@ -7,6 +7,7 @@ import { makeIdempotent, getCommandHelp, waspSays, + stripTrailingSlash, } from '../helpers/helpers.js'; import { clientTomlExistsInProject, @@ -105,7 +106,7 @@ async function deployClient(deploymentInfo: DeploymentInfo, { bui waspSays('Building web client for production...'); waspSays('If you configured a custom domain for the server, please run the command with an env variable: REACT_APP_API_URL=https://serverUrl.com wasp deploy fly deploy'); - const serverUrl = process.env.REACT_APP_API_URL || deploymentInfo.serverUrl; + const serverUrl = stripTrailingSlash(process.env.REACT_APP_API_URL ?? '') || deploymentInfo.serverUrl; await $`npm install`; await $`REACT_APP_API_URL=${serverUrl} npm run build`; diff --git a/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts b/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts index bc9512b91b..0b4b8372d2 100644 --- a/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts +++ b/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts @@ -141,3 +141,10 @@ export async function silence( $.verbose = verboseSetting; return proc; } + +export function stripTrailingSlash(url: string): string { + if (url.endsWith('/')) { + return url.slice(0, -1); + } + return url; +} \ No newline at end of file From 4bffcef11be386ba9471a7bebbf42230dbdb44a3 Mon Sep 17 00:00:00 2001 From: KayCee Date: Mon, 19 Aug 2024 20:40:03 +0530 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: Mihovil Ilakovac --- waspc/packages/deploy/src/providers/fly/deploy/deploy.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts b/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts index 6306cb990a..a4756f147a 100644 --- a/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts +++ b/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts @@ -104,9 +104,11 @@ async function deployClient(deploymentInfo: DeploymentInfo, { bui copyProjectClientTomlLocally(deploymentInfo.tomlFilePaths); waspSays('Building web client for production...'); - waspSays('If you configured a custom domain for the server, please run the command with an env variable: REACT_APP_API_URL=https://serverUrl.com wasp deploy fly deploy'); + waspSays('If you configured a custom domain for the server, you should run the command with an env variable: REACT_APP_API_URL=https://serverUrl.com wasp deploy fly deploy'); - const serverUrl = stripTrailingSlash(process.env.REACT_APP_API_URL ?? '') || deploymentInfo.serverUrl; + const serverUrl = process.env.REACT_APP_API_URL + ? stripTrailingSlash(process.env.REACT_APP_API_URL) + : deploymentInfo.serverUrl; await $`npm install`; await $`REACT_APP_API_URL=${serverUrl} npm run build`; From a6cfeb999909727b95baaacb6e17f4aa713976a3 Mon Sep 17 00:00:00 2001 From: case-E Date: Mon, 19 Aug 2024 20:46:54 +0530 Subject: [PATCH 4/5] add an extra line --- waspc/packages/deploy/src/providers/fly/helpers/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts b/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts index 0b4b8372d2..2c0db2b296 100644 --- a/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts +++ b/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts @@ -147,4 +147,4 @@ export function stripTrailingSlash(url: string): string { return url.slice(0, -1); } return url; -} \ No newline at end of file +} From d65fbd9d5129294c4ffbbd67dbb6f123ec5c0397 Mon Sep 17 00:00:00 2001 From: case-E Date: Mon, 2 Sep 2024 18:16:36 +0530 Subject: [PATCH 5/5] remove stripTrailingSlash helper --- waspc/packages/deploy/src/providers/fly/deploy/deploy.ts | 3 +-- waspc/packages/deploy/src/providers/fly/helpers/helpers.ts | 7 ------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts b/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts index a4756f147a..222cdeab95 100644 --- a/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts +++ b/waspc/packages/deploy/src/providers/fly/deploy/deploy.ts @@ -7,7 +7,6 @@ import { makeIdempotent, getCommandHelp, waspSays, - stripTrailingSlash, } from '../helpers/helpers.js'; import { clientTomlExistsInProject, @@ -107,7 +106,7 @@ async function deployClient(deploymentInfo: DeploymentInfo, { bui waspSays('If you configured a custom domain for the server, you should run the command with an env variable: REACT_APP_API_URL=https://serverUrl.com wasp deploy fly deploy'); const serverUrl = process.env.REACT_APP_API_URL - ? stripTrailingSlash(process.env.REACT_APP_API_URL) + ? process.env.REACT_APP_API_URL : deploymentInfo.serverUrl; await $`npm install`; await $`REACT_APP_API_URL=${serverUrl} npm run build`; diff --git a/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts b/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts index 2c0db2b296..bc9512b91b 100644 --- a/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts +++ b/waspc/packages/deploy/src/providers/fly/helpers/helpers.ts @@ -141,10 +141,3 @@ export async function silence( $.verbose = verboseSetting; return proc; } - -export function stripTrailingSlash(url: string): string { - if (url.endsWith('/')) { - return url.slice(0, -1); - } - return url; -}