fix: use absolute backend URL for highlight API calls

- Vite dev server doesn't proxy /api/v1/v2/ paths to backend
- Changed fetch URL and getHighlightUrl to use http://localhost:8000
- Fixed inline citation highlight URLs in buildCitationUrl
- Cleaned up debug code
This commit is contained in:
Woody 2026-04-29 10:39:01 +08:00
parent bcf4a853bf
commit b47e37f39b
2 changed files with 7 additions and 5 deletions

View File

@ -7,7 +7,8 @@ import { processCitations, processCitationsForSubq, extractCitedSources } from '
import { bulletizeMarkdown } from '../utils/citationParser' import { bulletizeMarkdown } from '../utils/citationParser'
function getHighlightUrl(document_id: string, chunk_index: number, sub_question: string): string { function getHighlightUrl(document_id: string, chunk_index: number, sub_question: string): string {
return `/api/v1/v2/highlights?document_id=${encodeURIComponent(document_id)}&chunk_index=${chunk_index}&sub_question=${encodeURIComponent(sub_question)}` 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)}`
} }
interface ResponsePanelProps { interface ResponsePanelProps {
@ -200,7 +201,7 @@ function SubQuestionSections({
setHighlightStatus('loading') setHighlightStatus('loading')
fetch('/api/v1/v2/highlights/batch', { fetch('http://localhost:8000/api/v1/v2/highlights/batch', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ targets }), body: JSON.stringify({ targets }),

View File

@ -61,7 +61,8 @@ export function processCitationsForSubq(
function buildCitationUrl(source: SourceMetadata, highlightReady?: boolean): string | null { function buildCitationUrl(source: SourceMetadata, highlightReady?: boolean): string | null {
if (highlightReady && source.document_id && source.sub_question_text) { if (highlightReady && source.document_id && source.sub_question_text) {
return `/api/v1/v2/highlights?document_id=${encodeURIComponent(source.document_id)}&chunk_index=${source.chunk_index}&sub_question=${encodeURIComponent(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)}`
} }
if (source.chunk_file_path) { if (source.chunk_file_path) {
return getPdfViewerUrl( return getPdfViewerUrl(