From 030491fc5af99772c4f4a0455b894ed4cdcf2e7e Mon Sep 17 00:00:00 2001 From: johnny2211 Date: Sun, 18 Jan 2026 17:26:44 +0100 Subject: [PATCH] Fix Docker deployment: Replace hardcoded localhost:3000 with environment-aware URLs - Fixed API client to respect empty VITE_API_URL for same-origin requests - Fixed video URL construction in videoPlaylist.ts - Fixed video URL construction in VideoUpload.tsx - All three files now use explicit undefined check instead of || operator - Enables proper same-origin requests via nginx proxy in Docker Co-Authored-By: Auggie --- packages/frontend/src/components/admin/VideoUpload.tsx | 2 +- packages/frontend/src/lib/api.ts | 2 +- packages/frontend/src/lib/videoPlaylist.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/components/admin/VideoUpload.tsx b/packages/frontend/src/components/admin/VideoUpload.tsx index cb6bacf..e3dca29 100644 --- a/packages/frontend/src/components/admin/VideoUpload.tsx +++ b/packages/frontend/src/components/admin/VideoUpload.tsx @@ -24,7 +24,7 @@ export function VideoUpload({ term, onSuccess, onCancel }: VideoUploadProps) { const existingVideos = term.media?.filter(m => m.kind === MediaKind.VIDEO) || []; // Construct full video URL - const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000'; + const API_URL = import.meta.env.VITE_API_URL !== undefined ? import.meta.env.VITE_API_URL : 'http://localhost:3000'; const getVideoUrl = (url: string) => url.startsWith('http') ? url : `${API_URL}${url}`; const validateFile = (file: File): boolean => { diff --git a/packages/frontend/src/lib/api.ts b/packages/frontend/src/lib/api.ts index a81d59a..44152af 100644 --- a/packages/frontend/src/lib/api.ts +++ b/packages/frontend/src/lib/api.ts @@ -1,6 +1,6 @@ import axios from 'axios'; -const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000'; +const API_URL = import.meta.env.VITE_API_URL !== undefined ? import.meta.env.VITE_API_URL : 'http://localhost:3000'; export const api = axios.create({ baseURL: API_URL, diff --git a/packages/frontend/src/lib/videoPlaylist.ts b/packages/frontend/src/lib/videoPlaylist.ts index 2fe013a..8993758 100644 --- a/packages/frontend/src/lib/videoPlaylist.ts +++ b/packages/frontend/src/lib/videoPlaylist.ts @@ -39,7 +39,7 @@ export function getVideoUrl(relativeUrl: string | null): string | null { if (relativeUrl.startsWith('http')) return relativeUrl; // Construct full URL using backend base URL - const baseUrl = import.meta.env.VITE_API_URL || 'http://localhost:3000'; + const baseUrl = import.meta.env.VITE_API_URL !== undefined ? import.meta.env.VITE_API_URL : 'http://localhost:3000'; return `${baseUrl}${relativeUrl}`; }