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
This commit is contained in:
2026-01-18 17:26:44 +01:00
parent 22fb4b9b20
commit 030491fc5a
3 changed files with 3 additions and 3 deletions

View File

@@ -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 => {

View File

@@ -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,

View File

@@ -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}`;
}