fix: use VITE_API_URL for API base path

This commit is contained in:
Felix Zett 2025-09-28 19:26:16 +02:00
parent bc90bb51d5
commit 827b6b5222
4 changed files with 9 additions and 7 deletions

View file

@ -35,11 +35,12 @@ services:
context: ./frontend
dockerfile: Dockerfile
target: prod
args:
VITE_API_URL: /api
expose:
- "80"
environment:
- NODE_ENV=production
- VITE_API_URL=/api
command: ["serve", "-s", "dist", "-l", "80"]
networks:
- nginx-proxy

View file

@ -1,5 +1,5 @@
services:
db:
packlist-db:
image: postgres:15-alpine
environment:
POSTGRES_PASSWORD: postgres
@ -9,13 +9,13 @@ services:
- "5432:5432"
volumes:
- db_data:/var/lib/postgresql/data
backend:
packlist-backend:
build:
context: ./backend
dockerfile: Dockerfile
target: dev
depends_on:
- db
- packlist-db
ports:
- "8000:8000"
- "5678:5678" # Port für Debugger
@ -24,7 +24,7 @@ services:
environment:
- PYTHONUNBUFFERED=1
command: ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
frontend:
packlist-frontend:
build:
context: ./frontend
dockerfile: Dockerfile

View file

@ -3,6 +3,8 @@ WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
ARG VITE_API_URL
ENV VITE_API_URL=$VITE_API_URL
RUN npm run build
FROM node:20-alpine AS prod

View file

@ -11,8 +11,7 @@ export interface Item {
trip_id: string;
}
// TODO use VITE_API_URL from compose instead of "/api"
export const API_BASE = "/api";
export const API_BASE = import.meta.env.VITE_API_URL || "http://localhost:8000";
export async function getSeed() {
return fetch(`${API_BASE}/dev/seed`).then(res => res.json());