Fix tous les appels API pour utiliser getApiUrl() au lieu de process.env
All checks were successful
Build and Push Docker Images / Build Frontend Image (push) Successful in 3m31s
All checks were successful
Build and Push Docker Images / Build Frontend Image (push) Successful in 3m31s
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 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { useState, useMemo } from "react"
|
import { useState, useMemo } from "react"
|
||||||
import { useQuery } from "@tanstack/react-query"
|
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 type { FilterParams, Track } from "@/lib/types"
|
||||||
import FilterPanel from "@/components/FilterPanel"
|
import FilterPanel from "@/components/FilterPanel"
|
||||||
import AudioPlayer from "@/components/AudioPlayer"
|
import AudioPlayer from "@/components/AudioPlayer"
|
||||||
@@ -90,7 +90,7 @@ export default function Home() {
|
|||||||
setIsScanning(true)
|
setIsScanning(true)
|
||||||
setScanStatus("Démarrage du scan...")
|
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',
|
method: 'POST',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ export default function Home() {
|
|||||||
// Poll scan status
|
// Poll scan status
|
||||||
const pollInterval = setInterval(async () => {
|
const pollInterval = setInterval(async () => {
|
||||||
try {
|
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()
|
const status = await statusResponse.json()
|
||||||
|
|
||||||
if (!status.is_scanning) {
|
if (!status.is_scanning) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useState, useRef, useEffect } from "react"
|
import { useState, useRef, useEffect } from "react"
|
||||||
import type { Track } from "@/lib/types"
|
import type { Track } from "@/lib/types"
|
||||||
|
import { getApiUrl } from "@/lib/api"
|
||||||
|
|
||||||
interface AudioPlayerProps {
|
interface AudioPlayerProps {
|
||||||
track: Track | null
|
track: Track | null
|
||||||
@@ -79,7 +80,7 @@ export default function AudioPlayer({ track, isPlaying, onPlayingChange }: Audio
|
|||||||
setIsLoadingWaveform(true)
|
setIsLoadingWaveform(true)
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`${process.env.NEXT_PUBLIC_API_URL}/api/audio/waveform/${trackId}`
|
`${getApiUrl()}/api/audio/waveform/${trackId}`
|
||||||
)
|
)
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
@@ -161,7 +162,7 @@ export default function AudioPlayer({ track, isPlaying, onPlayingChange }: Audio
|
|||||||
return (
|
return (
|
||||||
<div className="bg-gray-50 border-t border-gray-300 shadow-lg" style={{ height: '80px' }}>
|
<div className="bg-gray-50 border-t border-gray-300 shadow-lg" style={{ height: '80px' }}>
|
||||||
{/* Hidden audio element */}
|
{/* Hidden audio element */}
|
||||||
{track && <audio ref={audioRef} src={`${process.env.NEXT_PUBLIC_API_URL}/api/audio/stream/${track.id}`} />}
|
{track && <audio ref={audioRef} src={`${getApiUrl()}/api/audio/stream/${track.id}`} />}
|
||||||
|
|
||||||
<div className="h-full flex items-center gap-3 px-4">
|
<div className="h-full flex items-center gap-3 px-4">
|
||||||
{/* Play/Pause button */}
|
{/* Play/Pause button */}
|
||||||
@@ -300,7 +301,7 @@ export default function AudioPlayer({ track, isPlaying, onPlayingChange }: Audio
|
|||||||
{/* Download button */}
|
{/* Download button */}
|
||||||
{track && (
|
{track && (
|
||||||
<a
|
<a
|
||||||
href={`${process.env.NEXT_PUBLIC_API_URL}/api/audio/download/${track.id}`}
|
href={`${getApiUrl()}/api/audio/download/${track.id}`}
|
||||||
download
|
download
|
||||||
className="w-8 h-8 flex items-center justify-center text-gray-600 hover:text-gray-900 transition-colors rounded hover:bg-gray-200 flex-shrink-0"
|
className="w-8 h-8 flex items-center justify-center text-gray-600 hover:text-gray-900 transition-colors rounded hover:bg-gray-200 flex-shrink-0"
|
||||||
aria-label="Download"
|
aria-label="Download"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import type {
|
|||||||
} from './types'
|
} from './types'
|
||||||
|
|
||||||
// Get API URL from runtime config (injected at container startup) or fallback to env var
|
// Get API URL from runtime config (injected at container startup) or fallback to env var
|
||||||
function getApiUrl(): string {
|
export function getApiUrl(): string {
|
||||||
if (typeof window !== 'undefined' && (window as any).__RUNTIME_CONFIG__) {
|
if (typeof window !== 'undefined' && (window as any).__RUNTIME_CONFIG__) {
|
||||||
return (window as any).__RUNTIME_CONFIG__.API_URL
|
return (window as any).__RUNTIME_CONFIG__.API_URL
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user