diff --git a/archon-ui-main/src/components/layouts/MainLayout.tsx b/archon-ui-main/src/components/layouts/MainLayout.tsx index 5ea07ee..acc9188 100644 --- a/archon-ui-main/src/components/layouts/MainLayout.tsx +++ b/archon-ui-main/src/components/layouts/MainLayout.tsx @@ -45,7 +45,7 @@ export const MainLayout: React.FC = ({ const timeoutId = setTimeout(() => controller.abort(), 5000); // Check if backend is responding with a simple health check - const response = await fetch(`${credentialsService['baseUrl']}/health`, { + const response = await fetch(`${credentialsService['baseUrl']}/api/health`, { method: 'GET', signal: controller.signal }); @@ -212,4 +212,4 @@ export const MainLayout: React.FC = ({ ; -}; \ No newline at end of file +}; diff --git a/archon-ui-main/src/config/api.ts b/archon-ui-main/src/config/api.ts index ec3eb25..45e65b3 100644 --- a/archon-ui-main/src/config/api.ts +++ b/archon-ui-main/src/config/api.ts @@ -7,16 +7,16 @@ // Get the API URL from environment or construct it export function getApiUrl(): string { + // For relative URLs in production (goes through proxy) + if (import.meta.env.PROD === 'true') { + return ''; + } + // Check if VITE_API_URL is provided (set by docker-compose) if (import.meta.env.VITE_API_URL) { return import.meta.env.VITE_API_URL; } - // For relative URLs in production (goes through proxy) - if (import.meta.env.PROD) { - return ''; - } - // For development, construct from window location const protocol = window.location.protocol; const host = window.location.hostname; @@ -61,4 +61,4 @@ export function getWebSocketUrl(): string { // Export commonly used values export const API_BASE_URL = '/api'; // Always use relative URL for API calls export const API_FULL_URL = getApiUrl(); -export const WS_URL = getWebSocketUrl(); \ No newline at end of file +export const WS_URL = getWebSocketUrl(); diff --git a/archon-ui-main/vite.config.ts b/archon-ui-main/vite.config.ts index f6b7563..f32dfc8 100644 --- a/archon-ui-main/vite.config.ts +++ b/archon-ui-main/vite.config.ts @@ -280,6 +280,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { host: '0.0.0.0', // Listen on all network interfaces with explicit IP port: parseInt(process.env.ARCHON_UI_PORT || env.ARCHON_UI_PORT || '3737'), // Use configurable port strictPort: true, // Exit if port is in use + allowedHosts: [env.HOST, 'localhost', '127.0.0.1'], proxy: { '/api': { target: `http://${host}:${port}`, @@ -308,6 +309,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { define: { 'import.meta.env.VITE_HOST': JSON.stringify(host), 'import.meta.env.VITE_PORT': JSON.stringify(port), + 'import.meta.env.PROD': JSON.stringify(env.PROD || false), }, resolve: { alias: { diff --git a/docker-compose.yml b/docker-compose.yml index 28c3f95..a7a40ca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -154,6 +154,7 @@ services: - VITE_ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181} - ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181} - HOST=${HOST:-localhost} + - PROD=${PROD:-false} networks: - app-network healthcheck: