Skip to content

Commit 8a78208

Browse files
Clément VALENTINclaude
andcommitted
fix: utiliser window.__ENV__ pour l'URL API dans ApiDocs
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 3ac244f commit 8a78208

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

apps/web/src/pages/ApiDocs.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@ import { useEffect, useMemo } from 'react'
55
import { useThemeStore } from '@/stores/themeStore'
66
import { Link } from 'react-router-dom'
77

8+
// Runtime environment from env.js (generated at container startup)
9+
declare global {
10+
interface Window {
11+
__ENV__?: {
12+
VITE_API_BASE_URL?: string
13+
VITE_BACKEND_URL?: string
14+
}
15+
}
16+
}
17+
818
export default function ApiDocs() {
919
// Get the access token from localStorage
1020
const accessToken = useMemo(() => localStorage.getItem('access_token'), [])
1121
const { isDark } = useThemeStore()
12-
const apiBaseUrl = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8081'
22+
// Use runtime config first, then build-time env, then default
23+
const apiBaseUrl = window.__ENV__?.VITE_API_BASE_URL || import.meta.env.VITE_API_BASE_URL || '/api'
1324

1425
useEffect(() => {
1526
// Hide the "Explore" link and customize Swagger UI colors

0 commit comments

Comments
 (0)