@@ -20,6 +20,13 @@ function stripTrailingSlash(url: string): string {
2020}
2121
2222const backendBase = ( ( ) => {
23+ // Try runtime configuration first (for Azure App Service)
24+ const runtimeBase = ( window as any ) ?. runtimeConfig ?. VITE_BACKEND_BASE_URL ;
25+ if ( runtimeBase && runtimeBase . startsWith ( 'http' ) ) {
26+ return stripTrailingSlash ( runtimeBase ) ;
27+ }
28+
29+ // Fall back to build-time environment
2330 const base = import . meta. env . VITE_BACKEND_BASE_URL ?. trim ( ) ;
2431 if ( base ) return stripTrailingSlash ( base ) ;
2532
@@ -33,6 +40,13 @@ const backendBase = (() => {
3340} ) ( ) ;
3441
3542const loginBase = ( ( ) => {
43+ // Try runtime configuration first (for Azure App Service)
44+ const runtimeBase = ( window as any ) ?. runtimeConfig ?. VITE_LOGIN_BASE_URL ;
45+ if ( runtimeBase && runtimeBase . startsWith ( 'http' ) ) {
46+ return stripTrailingSlash ( runtimeBase ) ;
47+ }
48+
49+ // Fall back to build-time environment
3650 const base = import . meta. env . VITE_LOGIN_BASE_URL ?. trim ( ) ;
3751 if ( base ) return stripTrailingSlash ( base ) ;
3852
@@ -53,18 +67,38 @@ export const ENV_URLS = {
5367 oauthToken : loginBase ? `${ loginBase } /connect/token` : import . meta. env . VITE_OAUTH_TOKEN_URL || '' ,
5468} ;
5569
70+ // Debug environment loading
71+ console . log ( '🔍 Environment Debug:' , {
72+ backendBase,
73+ loginBase,
74+ 'import.meta.env.VITE_BACKEND_BASE_URL' : import . meta. env . VITE_BACKEND_BASE_URL ,
75+ 'import.meta.env.VITE_LOGIN_BASE_URL' : import . meta. env . VITE_LOGIN_BASE_URL ,
76+ 'import.meta.env.VITE_OAUTH_WEB_CLIENT_ID' : import . meta. env . VITE_OAUTH_WEB_CLIENT_ID ? 'SET' : 'NOT SET' ,
77+ ENV_URLS
78+ } ) ;
79+
5680// OAuth Web Client Configuration (for authorization code flow)
57- // Function to get OAuth client ID - simplified approach
81+ // Function to get OAuth client ID - with runtime support
5882function getOAuthClientId ( ) : string {
59- // Use build-time environment variable directly
60- // This will be set during the Docker build process in Azure
83+ // Try runtime configuration first (for Azure App Service)
84+ const runtimeClientId = ( window as any ) ?. runtimeConfig ?. VITE_OAUTH_WEB_CLIENT_ID ;
85+ if ( runtimeClientId && runtimeClientId . length > 10 ) {
86+ return runtimeClientId ;
87+ }
88+
89+ // Fall back to build-time environment variable
6190 return import . meta. env . VITE_OAUTH_WEB_CLIENT_ID || '' ;
6291}
6392
64- // Function to get OAuth client secret - simplified approach
93+ // Function to get OAuth client secret - with runtime support
6594function getOAuthClientSecret ( ) : string {
66- // Use build-time environment variable directly
67- // This will be set during the Docker build process in Azure
95+ // Try runtime configuration first (for Azure App Service)
96+ const runtimeClientSecret = ( window as any ) ?. runtimeConfig ?. VITE_OAUTH_WEB_CLIENT_SECRET ;
97+ if ( runtimeClientSecret && runtimeClientSecret . length > 10 ) {
98+ return runtimeClientSecret ;
99+ }
100+
101+ // Fall back to build-time environment variable
68102 return import . meta. env . VITE_OAUTH_WEB_CLIENT_SECRET || '' ;
69103}
70104
@@ -92,10 +126,22 @@ export const OAUTH_CONFIG = {
92126} ;
93127
94128export function assertRequiredUrls ( ) {
129+ console . log ( '🔍 Asserting required URLs:' , ENV_URLS ) ;
130+
95131 if ( ! ENV_URLS . graphql ) {
132+ console . error ( '❌ GraphQL endpoint is not configured:' , {
133+ backendBase,
134+ 'VITE_BACKEND_BASE_URL' : import . meta. env . VITE_BACKEND_BASE_URL ,
135+ 'VITE_GRAPHQL_URL' : import . meta. env . VITE_GRAPHQL_URL
136+ } ) ;
96137 throw new Error ( 'GraphQL endpoint is not configured. Set VITE_BACKEND_BASE_URL or VITE_GRAPHQL_URL.' ) ;
97138 }
98139 if ( ! ENV_URLS . oauthToken ) {
140+ console . error ( '❌ OAuth token endpoint is not configured:' , {
141+ loginBase,
142+ 'VITE_LOGIN_BASE_URL' : import . meta. env . VITE_LOGIN_BASE_URL ,
143+ 'VITE_OAUTH_TOKEN_URL' : import . meta. env . VITE_OAUTH_TOKEN_URL
144+ } ) ;
99145 throw new Error ( 'OAuth token endpoint is not configured. Set VITE_LOGIN_BASE_URL or VITE_OAUTH_TOKEN_URL.' ) ;
100146 }
101147}
0 commit comments