mirror of
https://github.com/coleam00/Archon.git
synced 2025-12-24 02:39:17 -05:00
Fix proxy when specifying PROD=true
This commit is contained in:
@@ -45,7 +45,7 @@ export const MainLayout: React.FC<MainLayoutProps> = ({
|
|||||||
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
||||||
|
|
||||||
// Check if backend is responding with a simple health check
|
// 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',
|
method: 'GET',
|
||||||
signal: controller.signal
|
signal: controller.signal
|
||||||
});
|
});
|
||||||
@@ -212,4 +212,4 @@ export const MainLayout: React.FC<MainLayoutProps> = ({
|
|||||||
<ArchonChatPanel data-id="archon-chat" />
|
<ArchonChatPanel data-id="archon-chat" />
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,16 +7,16 @@
|
|||||||
|
|
||||||
// Get the API URL from environment or construct it
|
// Get the API URL from environment or construct it
|
||||||
export function getApiUrl(): string {
|
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)
|
// Check if VITE_API_URL is provided (set by docker-compose)
|
||||||
if (import.meta.env.VITE_API_URL) {
|
if (import.meta.env.VITE_API_URL) {
|
||||||
return 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
|
// For development, construct from window location
|
||||||
const protocol = window.location.protocol;
|
const protocol = window.location.protocol;
|
||||||
const host = window.location.hostname;
|
const host = window.location.hostname;
|
||||||
@@ -61,4 +61,4 @@ export function getWebSocketUrl(): string {
|
|||||||
// Export commonly used values
|
// Export commonly used values
|
||||||
export const API_BASE_URL = '/api'; // Always use relative URL for API calls
|
export const API_BASE_URL = '/api'; // Always use relative URL for API calls
|
||||||
export const API_FULL_URL = getApiUrl();
|
export const API_FULL_URL = getApiUrl();
|
||||||
export const WS_URL = getWebSocketUrl();
|
export const WS_URL = getWebSocketUrl();
|
||||||
|
|||||||
@@ -280,6 +280,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
|||||||
host: '0.0.0.0', // Listen on all network interfaces with explicit IP
|
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
|
port: parseInt(process.env.ARCHON_UI_PORT || env.ARCHON_UI_PORT || '3737'), // Use configurable port
|
||||||
strictPort: true, // Exit if port is in use
|
strictPort: true, // Exit if port is in use
|
||||||
|
allowedHosts: [env.HOST, 'localhost', '127.0.0.1'],
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: `http://${host}:${port}`,
|
target: `http://${host}:${port}`,
|
||||||
@@ -308,6 +309,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
|||||||
define: {
|
define: {
|
||||||
'import.meta.env.VITE_HOST': JSON.stringify(host),
|
'import.meta.env.VITE_HOST': JSON.stringify(host),
|
||||||
'import.meta.env.VITE_PORT': JSON.stringify(port),
|
'import.meta.env.VITE_PORT': JSON.stringify(port),
|
||||||
|
'import.meta.env.PROD': JSON.stringify(env.PROD || false),
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ services:
|
|||||||
- VITE_ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181}
|
- VITE_ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181}
|
||||||
- ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181}
|
- ARCHON_SERVER_PORT=${ARCHON_SERVER_PORT:-8181}
|
||||||
- HOST=${HOST:-localhost}
|
- HOST=${HOST:-localhost}
|
||||||
|
- PROD=${PROD:-false}
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
|||||||
Reference in New Issue
Block a user