Fix proxy when specifying PROD=true

This commit is contained in:
Michael Hines 2025-08-25 00:13:37 -05:00 committed by Wirasm
parent 51a8c74525
commit e1d3c6ed20
4 changed files with 11 additions and 8 deletions

View File

@ -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
});

View File

@ -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;

View File

@ -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: {

View File

@ -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: