Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ ARCHON_AGENTS_PORT=8052
ARCHON_UI_PORT=3737
ARCHON_DOCS_PORT=3838

# When enabled, PROD mode will proxy ARCHON_SERVER_PORT through ARCHON_UI_PORT. This exposes both the
# Archon UI and API through a single port. This is useful when deploying Archon behind a reverse
# proxy where you want to expose the frontend on a single external domain.
PROD=false

# Embedding Configuration
# Dimensions for embedding vectors (1536 for OpenAI text-embedding-3-small)
EMBEDDING_DIMENSIONS=1536
Expand All @@ -51,4 +56,4 @@ EMBEDDING_DIMENSIONS=1536
# * CRAWL_MAX_CONCURRENT (default: 10) - Max concurrent pages per crawl operation
# * CRAWL_BATCH_SIZE (default: 50) - URLs processed per batch
# * MEMORY_THRESHOLD_PERCENT (default: 80) - Memory % before throttling
# * DISPATCHER_CHECK_INTERVAL (default: 0.5) - Memory check interval in seconds
# * DISPATCHER_CHECK_INTERVAL (default: 0.5) - Memory check interval in seconds
4 changes: 2 additions & 2 deletions archon-ui-main/src/components/layouts/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const MainLayout: React.FC<MainLayoutProps> = ({
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
});
Comment on lines +48 to 51
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid double-prefixing /api by using centralized API base path

If credentialsService.baseUrl already contains /api, this becomes /api/api/health. Prefer the centralized helper to construct the base path.

Apply:

@@
-import { credentialsService } from '../../services/credentialsService';
+import { credentialsService } from '../../services/credentialsService';
+import { getApiBasePath } from '../../config/api';
@@
-        const response = await fetch(`${credentialsService['baseUrl']}/api/health`, {
+        const response = await fetch(`${getApiBasePath()}/health`, {
           method: 'GET',
           signal: controller.signal
         });

This keeps the health check correct regardless of whether you’re using a relative base or a full URL.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const response = await fetch(`${credentialsService['baseUrl']}/api/health`, {
method: 'GET',
signal: controller.signal
});
// archon-ui-main/src/components/layouts/MainLayout.tsx
import React from 'react';
import { credentialsService } from '../../services/credentialsService';
import { getApiBasePath } from '../../config/api';
// … other code …
const response = await fetch(`${getApiBasePath()}/health`, {
method: 'GET',
signal: controller.signal
});
// … other code …
🤖 Prompt for AI Agents
In archon-ui-main/src/components/layouts/MainLayout.tsx around lines 48 to 51,
the health check concatenates credentialsService.baseUrl with a hardcoded "/api"
which can produce "/api/api/health" when baseUrl already contains "/api"; change
the call to use the centralized API base-path helper (or derive a normalized
base without the "/api" prefix) and then append only "/health" so the final URL
is constructed consistently (e.g., use the app's API base helper to get baseUrl
and call `${apiBase}/health` or normalize credentialsService.baseUrl to strip
any trailing "/api" before appending "/health").

Expand Down Expand Up @@ -212,4 +212,4 @@ export const MainLayout: React.FC<MainLayoutProps> = ({
<ArchonChatPanel data-id="archon-chat" />
</div>
</div>;
};
};
12 changes: 6 additions & 6 deletions archon-ui-main/src/config/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

// Get the API URL from environment or construct it
export function getApiUrl(): string {
// 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 '';
}

// 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 development, construct from window location
const protocol = window.location.protocol;
const host = window.location.hostname;
Expand Down Expand Up @@ -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();
export const WS_URL = getWebSocketUrl();
6 changes: 4 additions & 2 deletions archon-ui-main/test/config/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ describe('API Configuration', () => {
it('should return empty string in production mode', async () => {
// Set production mode
(import.meta.env as any).PROD = true;
delete (import.meta.env as any).VITE_API_URL;

// It should not use VITE_API_URL
(import.meta.env as any).VITE_API_URL = 'http://custom-api:9999';

const { getApiUrl } = await import('../../src/config/api');
expect(getApiUrl()).toBe('');
Expand Down Expand Up @@ -233,4 +235,4 @@ describe('MCP Client Service Configuration', () => {
expect(error).toBeDefined();
}
});
});
});
2 changes: 2 additions & 0 deletions archon-ui-main/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down Expand Up @@ -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': env.PROD === 'true',
},
resolve: {
alias: {
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down