Fix proxy when specifying PROD=true
This commit is contained in:
parent
51a8c74525
commit
e1d3c6ed20
@ -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
|
||||
});
|
||||
@ -212,4 +212,4 @@ export const MainLayout: React.FC<MainLayoutProps> = ({
|
||||
<ArchonChatPanel data-id="archon-chat" />
|
||||
</div>
|
||||
</div>;
|
||||
};
|
||||
};
|
||||
|
||||
@ -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();
|
||||
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
|
||||
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: {
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user