diff --git a/frontend/src/components/ResponsePanel.tsx b/frontend/src/components/ResponsePanel.tsx index ea0ad43..7cb6319 100644 --- a/frontend/src/components/ResponsePanel.tsx +++ b/frontend/src/components/ResponsePanel.tsx @@ -7,9 +7,10 @@ import { getPdfViewerUrl } from '../lib/api' import { processCitations, processCitationsForSubq, extractCitedSources, highlightTerms } from '../utils/citationParser' import { bulletizeMarkdown } from '../utils/citationParser' +const V2_BASE = `${import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:8000/api/v1'}/v2` + function getHighlightUrl(document_id: string, chunk_index: number, sub_question: string): string { - const base = 'http://localhost:8000/api/v1/v2' - return `${base}/highlights?document_id=${encodeURIComponent(document_id)}&chunk_index=${chunk_index}&sub_question=${encodeURIComponent(sub_question)}` + return `${V2_BASE}/highlights?document_id=${encodeURIComponent(document_id)}&chunk_index=${chunk_index}&sub_question=${encodeURIComponent(sub_question)}` } interface ResponsePanelProps { @@ -220,8 +221,8 @@ function SubQuestionSections({ const startTime = performance.now() const url = historyId - ? `http://localhost:8000/api/v1/v2/highlights/batch?history_id=${historyId}` - : 'http://localhost:8000/api/v1/v2/highlights/batch' + ? `${V2_BASE}/highlights/batch?history_id=${historyId}` + : `${V2_BASE}/highlights/batch` fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, diff --git a/frontend/src/utils/citationParser.ts b/frontend/src/utils/citationParser.ts index abb78d1..b224bd6 100644 --- a/frontend/src/utils/citationParser.ts +++ b/frontend/src/utils/citationParser.ts @@ -61,8 +61,8 @@ export function processCitationsForSubq( function buildCitationUrl(source: SourceMetadata, highlightReady?: boolean): string | null { if (highlightReady && source.document_id && source.sub_question_text) { - const base = 'http://localhost:8000/api/v1/v2' - return `${base}/highlights?document_id=${encodeURIComponent(source.document_id)}&chunk_index=${source.chunk_index}&sub_question=${encodeURIComponent(source.sub_question_text)}` + const v2Base = `${import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:8000/api/v1'}/v2` + return `${v2Base}/highlights?document_id=${encodeURIComponent(source.document_id)}&chunk_index=${source.chunk_index}&sub_question=${encodeURIComponent(source.sub_question_text)}` } if (source.chunk_file_path) { return getPdfViewerUrl(