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'
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 {
@ -171,7 +172,7 @@ function SubQuestionSections({
useEffect(() => {
if (!answer || isLoading || !subQuestionSources.length) return
const targets: Array<{
document_id: string
chunk_index: number
@ -200,7 +201,7 @@ function SubQuestionSections({
setHighlightStatus('loading')
fetch('/api/v1/v2/highlights/batch', {
fetch('http://localhost:8000/api/v1/v2/highlights/batch', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ targets }),
@ -433,7 +434,7 @@ function FlatResponse({
return (
<div className="p-4 space-y-4">
<div className="space-y-2">
<div className="flex items-start justify-between">
<div className="flex items-start justify-between">
<div className="flex-1" />
<button
data-testid="copy-answer-btn"

View File

@ -61,7 +61,8 @@ export function processCitationsForSubq(
function buildCitationUrl(source: SourceMetadata, highlightReady?: boolean): string | null {
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) {
return getPdfViewerUrl(