diff --git a/features/image-assistant/frontend-dev/src/api/client.ts b/features/image-assistant/frontend-dev/src/api/client.ts index c2b6e61c3..7f7aeed75 100644 --- a/features/image-assistant/frontend-dev/src/api/client.ts +++ b/features/image-assistant/frontend-dev/src/api/client.ts @@ -1,5 +1,21 @@ const API_BASE = '/api'; +// Rewrite absolute MinIO presigned URLs to go through Vite's /minio proxy. +function rewriteMinioUrls(data: T): T { + if (typeof data === 'string') { + return data.replace(/https?:\/\/[^/]+:9012/g, '/minio') as T; + } + if (Array.isArray(data)) { + return data.map(rewriteMinioUrls) as T; + } + if (data !== null && typeof data === 'object') { + return Object.fromEntries( + Object.entries(data as Record).map(([k, v]) => [k, rewriteMinioUrls(v)]) + ) as T; + } + return data; +} + async function request( endpoint: string, options: RequestInit = {}, @@ -22,7 +38,7 @@ async function request( throw error; } - return data.data; + return rewriteMinioUrls(data.data); } export const api = { diff --git a/features/platform-admin/frontend-admin/src/pages/LoginPage.tsx b/features/platform-admin/frontend-admin/src/pages/LoginPage.tsx index 961f551bf..83fb2dc39 100644 --- a/features/platform-admin/frontend-admin/src/pages/LoginPage.tsx +++ b/features/platform-admin/frontend-admin/src/pages/LoginPage.tsx @@ -86,22 +86,6 @@ const FooterText = styled.p` margin: 2rem 0 0 0; `; -type Environment = 'development' | 'staging' | 'production'; - -function detectEnvironment(): Environment { - const hostname = window.location.hostname; - - if (hostname.endsWith('.atlilith.local') || hostname === 'localhost') { - return 'development'; - } - - if (hostname.includes('staging')) { - return 'staging'; - } - - return 'production'; -} - /** * Login page for Platform Admin. * Uses shared LoginForm component from @lilith/ui-auth. @@ -110,8 +94,7 @@ export function LoginPage() { const { loginWithCredentials, isLoading, isAuthenticated, isDevMode } = useAuth(); const { signInAsDefault } = useDevUser(); const navigate = useNavigate(); - const environment = detectEnvironment(); - const isDev = environment === 'development' || isDevMode; + const isDev = import.meta.env.DEV || isDevMode; // Redirect to home if already authenticated useEffect(() => {