From 4d8fa57ab26baa7bab38c8d2530e019636ef3549 Mon Sep 17 00:00:00 2001 From: Benoit Date: Wed, 24 Dec 2025 10:54:38 +0100 Subject: [PATCH] Fix tous les appels API pour utiliser getApiUrl() au lieu de process.env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problème: Le commit précédent n'avait corrigé que api.ts, mais AudioPlayer et page.tsx utilisaient encore directement process.env.NEXT_PUBLIC_API_URL, ce qui ignorait la config runtime. Fichiers corrigés: 1. lib/api.ts: - Export getApiUrl() pour usage externe 2. app/page.tsx: - Import getApiUrl - /api/library/scan: process.env → getApiUrl() - /api/library/scan/status: process.env → getApiUrl() 3. components/AudioPlayer.tsx: - Import getApiUrl - /api/audio/waveform: process.env → getApiUrl() - /api/audio/stream: process.env → getApiUrl() - /api/audio/download: process.env → getApiUrl() Maintenant TOUS les appels API utilisent la config runtime (window.__RUNTIME_CONFIG__) côté client. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- frontend/app/page.tsx | 6 +++--- frontend/components/AudioPlayer.tsx | 7 ++++--- frontend/lib/api.ts | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index 706dd5e..12b46b6 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -2,7 +2,7 @@ import { useState, useMemo } from "react" import { useQuery } from "@tanstack/react-query" -import { getTracks } from "@/lib/api" +import { getTracks, getApiUrl } from "@/lib/api" import type { FilterParams, Track } from "@/lib/types" import FilterPanel from "@/components/FilterPanel" import AudioPlayer from "@/components/AudioPlayer" @@ -90,7 +90,7 @@ export default function Home() { setIsScanning(true) setScanStatus("Démarrage du scan...") - const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/library/scan`, { + const response = await fetch(`${getApiUrl()}/api/library/scan`, { method: 'POST', }) @@ -103,7 +103,7 @@ export default function Home() { // Poll scan status const pollInterval = setInterval(async () => { try { - const statusResponse = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/library/scan/status`) + const statusResponse = await fetch(`${getApiUrl()}/api/library/scan/status`) const status = await statusResponse.json() if (!status.is_scanning) { diff --git a/frontend/components/AudioPlayer.tsx b/frontend/components/AudioPlayer.tsx index ba7d332..24165ba 100644 --- a/frontend/components/AudioPlayer.tsx +++ b/frontend/components/AudioPlayer.tsx @@ -2,6 +2,7 @@ import { useState, useRef, useEffect } from "react" import type { Track } from "@/lib/types" +import { getApiUrl } from "@/lib/api" interface AudioPlayerProps { track: Track | null @@ -79,7 +80,7 @@ export default function AudioPlayer({ track, isPlaying, onPlayingChange }: Audio setIsLoadingWaveform(true) try { const response = await fetch( - `${process.env.NEXT_PUBLIC_API_URL}/api/audio/waveform/${trackId}` + `${getApiUrl()}/api/audio/waveform/${trackId}` ) if (response.ok) { const data = await response.json() @@ -161,7 +162,7 @@ export default function AudioPlayer({ track, isPlaying, onPlayingChange }: Audio return (
{/* Hidden audio element */} - {track &&