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 context: ./frontend
dockerfile: Dockerfile dockerfile: Dockerfile
target: prod target: prod
args:
VITE_API_URL: /api
expose: expose:
- "80" - "80"
environment: environment:
- NODE_ENV=production - NODE_ENV=production
- VITE_API_URL=/api
command: ["serve", "-s", "dist", "-l", "80"] command: ["serve", "-s", "dist", "-l", "80"]
networks: networks:
- nginx-proxy - nginx-proxy

View file

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

View file

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

View file

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