@@ -3,15 +3,24 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
33import { firstValueFrom } from 'rxjs' ;
44import { ArtifactProposal , IssueProposal , PlanProposal , PrReviewProposal , CodeChangeProposal , PrProposal , ReviewPosted , ChatMessage , ToolUsage , ProposedFile } from '../models/chat.models' ;
55
6- const API_URL = '/api/chat/complete' ;
7- const CONFIRM_REVIEW_URL = '/api/confirm/review' ;
8- const CONFIRM_CODE_CHANGE_URL = '/api/confirm/code-change' ;
9- const CONFIRM_PR_URL = '/api/confirm/pr' ;
10-
11- const ENSEMBLE_DESIGN_URL = '/api/ensemble/design' ;
12- const ENSEMBLE_CODE_URL = '/api/ensemble/code' ;
13- const ENSEMBLE_REVIEW_URL = '/api/ensemble/review' ;
14- const ARTIFACT_GENERATE_URL = '/api/artifact/generate' ;
6+ // Empty (docker-compose, nginx proxies /api/) or the unsubstituted `ng serve`
7+ // placeholder both resolve to relative URLs. Only set to an absolute origin
8+ // when the SPA is hosted separately from the backend (e.g. Azure Static Web Apps).
9+ const API_BASE = ( ( ) => {
10+ const raw = ( window as any ) . __env ?. apiBaseUrl ;
11+ if ( ! raw || raw . startsWith ( '${' ) ) return '' ;
12+ return raw . replace ( / \/ + $ / , '' ) ;
13+ } ) ( ) ;
14+
15+ const API_URL = `${ API_BASE } /api/chat/complete` ;
16+ const CONFIRM_REVIEW_URL = `${ API_BASE } /api/confirm/review` ;
17+ const CONFIRM_CODE_CHANGE_URL = `${ API_BASE } /api/confirm/code-change` ;
18+ const CONFIRM_PR_URL = `${ API_BASE } /api/confirm/pr` ;
19+
20+ const ENSEMBLE_DESIGN_URL = `${ API_BASE } /api/ensemble/design` ;
21+ const ENSEMBLE_CODE_URL = `${ API_BASE } /api/ensemble/code` ;
22+ const ENSEMBLE_REVIEW_URL = `${ API_BASE } /api/ensemble/review` ;
23+ const ARTIFACT_GENERATE_URL = `${ API_BASE } /api/artifact/generate` ;
1524
1625export interface CapacityStatus {
1726 tier : number ;
0 commit comments