diff --git a/docker-compose.yml b/docker-compose.yml index d818c420d..7f2233230 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,10 +16,8 @@ services: container_name: frontend environment: - ORIGIN=http://localhost:3000 - build: - context: ./frontend - args: - PUBLIC_BACKEND_API_URL=http://backend:8000/api + build: ./frontend depends_on: - backend ports: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 59e3c3fcc..f16ab363c 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,8 +1,7 @@ FROM node:21-alpine AS builder WORKDIR /app -ARG PUBLIC_BACKEND_API_URL -ENV PUBLIC_BACKEND_API_URL=$PUBLIC_BACKEND_API_URL +ENV PUBLIC_BACKEND_API_URL=foo COPY package*.json . COPY . . diff --git a/frontend/src/lib/utils/constants.ts b/frontend/src/lib/utils/constants.ts index 8844dff4b..479f2a978 100644 --- a/frontend/src/lib/utils/constants.ts +++ b/frontend/src/lib/utils/constants.ts @@ -1,6 +1,6 @@ -import { PUBLIC_BACKEND_API_URL } from '$env/static/public'; +import { env } from '$env/dynamic/public'; -export const BASE_API_URL = `${PUBLIC_BACKEND_API_URL}`; +export const BASE_API_URL = `${env.PUBLIC_BACKEND_API_URL}`; export const RISK_COLOR_PALETTE: string[] = ['#BBF7D0', '#BEF264', '#FEF08A', '#FBBF24', '#F87171']; export const COMPLIANCE_COLOR_MAP = { diff --git a/frontend/src/routes/(app)/scoring-assistant/+page.server.ts b/frontend/src/routes/(app)/scoring-assistant/+page.server.ts index edbe5e79c..54340f541 100644 --- a/frontend/src/routes/(app)/scoring-assistant/+page.server.ts +++ b/frontend/src/routes/(app)/scoring-assistant/+page.server.ts @@ -1,10 +1,10 @@ -import { PUBLIC_BACKEND_API_URL } from '$env/static/public'; +import { BASE_API_URL } from '$lib/utils/constants'; import type { RiskMatrix, RiskMatrixJsonDefinition } from '$lib/utils/types'; import type { PageServerLoad } from './$types'; import { error } from '@sveltejs/kit'; export const load: PageServerLoad = async ({ fetch }) => { - const req = await fetch(`${PUBLIC_BACKEND_API_URL}/risk-matrices/`); + const req = await fetch(`${BASE_API_URL}/risk-matrices/`); const req_data = await req.json(); const risk_matrices: RiskMatrixJsonDefinition[] = req_data.results.map( diff --git a/frontend/tests/Dockerfile b/frontend/tests/Dockerfile index 6a899f209..596468561 100644 --- a/frontend/tests/Dockerfile +++ b/frontend/tests/Dockerfile @@ -2,8 +2,7 @@ FROM mcr.microsoft.com/playwright:v1.40.1 WORKDIR /app -ARG PUBLIC_BACKEND_API_URL -ENV PUBLIC_BACKEND_API_URL=$PUBLIC_BACKEND_API_URL +ENV PUBLIC_BACKEND_API_URL=foo COPY ../package*.json . RUN npm ci