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/VERSION b/VERSION index 3eefcb9d..7dea76ed 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.0.1 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({