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:
@@ -24,7 +24,7 @@ export function VideoUpload({ term, onSuccess, onCancel }: VideoUploadProps) {
|
|||||||
const existingVideos = term.media?.filter(m => m.kind === MediaKind.VIDEO) || [];
|
const existingVideos = term.media?.filter(m => m.kind === MediaKind.VIDEO) || [];
|
||||||
|
|
||||||
// Construct full video URL
|
// 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 getVideoUrl = (url: string) => url.startsWith('http') ? url : `${API_URL}${url}`;
|
||||||
|
|
||||||
const validateFile = (file: File): boolean => {
|
const validateFile = (file: File): boolean => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import axios from 'axios';
|
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({
|
export const api = axios.create({
|
||||||
baseURL: API_URL,
|
baseURL: API_URL,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export function getVideoUrl(relativeUrl: string | null): string | null {
|
|||||||
if (relativeUrl.startsWith('http')) return relativeUrl;
|
if (relativeUrl.startsWith('http')) return relativeUrl;
|
||||||
|
|
||||||
// Construct full URL using backend base URL
|
// 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}`;
|
return `${baseUrl}${relativeUrl}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user