Skip to content

Commit c7174d9

Browse files
author
Piotr Stachaczynski
committed
feat: release prep
1 parent 7db4c02 commit c7174d9

5 files changed

Lines changed: 29 additions & 14 deletions

File tree

.github/workflows/deploy-frontend.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ jobs:
2020
cache: npm
2121
cache-dependency-path: frontend/package-lock.json
2222

23-
- name: Inject TURNSTILE_SITE_KEY into env.js
23+
- name: Inject runtime env into env.js
2424
env:
2525
TURNSTILE_SITE_KEY: ${{ secrets.TURNSTILE_SITE_KEY }}
26+
API_BASE_URL: ${{ vars.API_BASE_URL }}
2627
run: envsubst < frontend/public/env.js > /tmp/env.js && mv /tmp/env.js frontend/public/env.js
2728

2829
- name: Install dependencies

frontend/docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
22
set -e
3-
envsubst '${TURNSTILE_SITE_KEY}' < /usr/share/nginx/html/env.js > /tmp/env.js
3+
envsubst '${TURNSTILE_SITE_KEY} ${API_BASE_URL}' < /usr/share/nginx/html/env.js > /tmp/env.js
44
mv /tmp/env.js /usr/share/nginx/html/env.js
55
exec nginx -g 'daemon off;'

frontend/public/env.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
window.__env = {
2-
turnstileSiteKey: '${TURNSTILE_SITE_KEY}'
2+
turnstileSiteKey: '${TURNSTILE_SITE_KEY}',
3+
apiBaseUrl: '${API_BASE_URL}'
34
};

frontend/src/app/interceptors/session.interceptor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import { inject } from '@angular/core';
33
import { catchError, from, switchMap, throwError } from 'rxjs';
44
import { SessionService } from '../services/session.service';
55

6-
const PROTECTED_PREFIXES = ['/api/chat', '/api/confirm', '/api/ensemble'];
6+
const PROTECTED_PREFIXES = ['/api/chat', '/api/confirm', '/api/ensemble', '/api/artifact'];
77

88
export const sessionInterceptor: HttpInterceptorFn = (req, next) => {
9-
if (!PROTECTED_PREFIXES.some(prefix => req.url.startsWith(prefix))) {
9+
// req.url may be relative ('/api/chat/complete') or absolute
10+
// (https://maindoc-backend.../api/chat/complete) when the SPA is hosted
11+
// separately from the backend, so match on the pathname only.
12+
const path = new URL(req.url, window.location.origin).pathname;
13+
if (!PROTECTED_PREFIXES.some(prefix => path.startsWith(prefix))) {
1014
return next(req);
1115
}
1216

frontend/src/app/services/chat.service.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,24 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
33
import { firstValueFrom } from 'rxjs';
44
import { 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

1625
export interface CapacityStatus {
1726
tier: number;

0 commit comments

Comments
 (0)