From 42674108064bc6ef6dec57e98364ddac3ef75d38 Mon Sep 17 00:00:00 2001 From: &mile Date: Thu, 12 Mar 2026 17:05:27 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(website):=20r?= =?UTF-8?q?ename=20VITE=5FPUBLIC=20env=20vars=20and=20add=20API=20base=20U?= =?UTF-8?q?RL=20validation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - rename VITE_PUBLIC_WEBSITE_URL to VITE_WEBSITE_BASE_URL and VITE_PUBLIC_API_URL to VITE_API_BASE_URL in compose.yml and Dockerfile build args - add early validation for VITE_API_BASE_URL in getResponseBodyFromAPI, returning a ClientError if undefined - extract apiBaseUrl to a local variable before constructing the fetch URL --- .workflows/.build/compose.yml | 4 +-- .workflows/.build/packages/website/Dockerfile | 8 ++--- .../src/utilities/getResponseBodyFromAPI.ts | 32 +++++++++++++------ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.workflows/.build/compose.yml b/.workflows/.build/compose.yml index bd893c1c..7ab6acde 100644 --- a/.workflows/.build/compose.yml +++ b/.workflows/.build/compose.yml @@ -32,5 +32,5 @@ services: context: ../.. dockerfile: .workflows/.build/packages/website/Dockerfile args: - - VITE_PUBLIC_WEBSITE_URL=${VITE_PUBLIC_WEBSITE_URL:-} - - VITE_PUBLIC_API_URL=${VITE_PUBLIC_API_URL:-} + - VITE_WEBSITE_BASE_URL=${VITE_WEBSITE_BASE_URL:-} + - VITE_API_BASE_URL=${VITE_API_BASE_URL:-} diff --git a/.workflows/.build/packages/website/Dockerfile b/.workflows/.build/packages/website/Dockerfile index 658c78ce..116b0e3f 100644 --- a/.workflows/.build/packages/website/Dockerfile +++ b/.workflows/.build/packages/website/Dockerfile @@ -3,12 +3,12 @@ FROM node:25-alpine AS base RUN npm install -g pnpm@10.26.1 # Define build arguments for environment variables -ARG VITE_PUBLIC_WEBSITE_URL -ARG VITE_PUBLIC_API_URL +ARG VITE_API_BASE_URL +ARG VITE_WEBSITE_BASE_URL # Set environment variables during the build process -ENV VITE_PUBLIC_WEBSITE_URL=$VITE_PUBLIC_WEBSITE_URL -ENV VITE_PUBLIC_API_URL=$VITE_PUBLIC_API_URL +ENV VITE_API_BASE_URL=$VITE_API_BASE_URL +ENV VITE_WEBSITE_BASE_URL=$VITE_WEBSITE_BASE_URL ENV NODE_OPTIONS="--max-old-space-size=4096" # Build the repo diff --git a/packages/website/src/utilities/getResponseBodyFromAPI.ts b/packages/website/src/utilities/getResponseBodyFromAPI.ts index 1439bd7a..3373688f 100644 --- a/packages/website/src/utilities/getResponseBodyFromAPI.ts +++ b/packages/website/src/utilities/getResponseBodyFromAPI.ts @@ -20,6 +20,21 @@ export async function getResponseBodyFromAPI< const abortController = parameters.signal ? undefined : new AbortController() const signal = parameters.signal ?? abortController!.signal try { + const apiBaseUrl = import.meta.env.VITE_API_BASE_URL + if (!apiBaseUrl) { + console.error( + "VITE_API_BASE_URL is not defined. The request will not be sent. " + + "Make sure the environment variable is set at build time.", + ) + return { + ok: false, + data: undefined, + error: new ClientError({ + message: "VITE_API_BASE_URL is not defined", + }), + } + } + const headers: Record = { "Content-Type": "application/json", } @@ -29,16 +44,13 @@ export async function getResponseBodyFromAPI< headers["X-Organization-Id"] = idOrganization } - const response = await fetch( - new URL(`${import.meta.env.VITE_API_BASE_URL}${parameters.routeDefinition.path}`), - { - method: "POST", - headers, - credentials: "include", - body: JSON.stringify(parameters.body), - signal, - }, - ) + const response = await fetch(new URL(`${apiBaseUrl}${parameters.routeDefinition.path}`), { + method: "POST", + headers, + credentials: "include", + body: JSON.stringify(parameters.body), + signal, + }) const jsonResponse = JSON.parse((await response.text()) || "{}") if (response.ok === false) { throw new ClientError({ From 6d7dbc7dfe1996a331404e2950c931563ca302f5 Mon Sep 17 00:00:00 2001 From: &mile Date: Thu, 12 Mar 2026 17:06:40 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A7=20chore:=20bump=20version=20to?= =?UTF-8?q?=201.0.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3eefcb9d..7dea76ed 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.0.1