fix: use relative /api/v1 fallback instead of hardcoded localhost:8000

API URLs now resolve relative to the page origin, working for both local dev (via Vite proxy) and remote production deployments.

Also fixes useFullTranscript which had a double /api/v1 path bug when VITE_API_BASE_URL was set.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Woody 2026-05-18 17:27:28 +08:00
parent a54d688867
commit 67d2bddeb6
5 changed files with 7 additions and 7 deletions

View File

@ -7,7 +7,7 @@ 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`
const V2_BASE = `${import.meta.env.VITE_API_BASE_URL ?? '/api/v1'}/v2`
function getHighlightUrl(document_id: string, chunk_index: number, sub_question: string): string {
return `${V2_BASE}/highlights?document_id=${encodeURIComponent(document_id)}&chunk_index=${chunk_index}&sub_question=${encodeURIComponent(sub_question)}`

View File

@ -13,8 +13,8 @@ export function useFullTranscript({ videoId }: UseFullTranscriptOptions) {
setIsLoading(true)
setError(null)
try {
const base = import.meta.env.VITE_API_BASE_URL ?? ''
const resp = await fetch(`${base}/api/v1/video/${videoId}/transcribe`, {
const base = import.meta.env.VITE_API_BASE_URL ?? '/api/v1'
const resp = await fetch(`${base}/video/${videoId}/transcribe`, {
method: 'POST',
})
if (!resp.ok) {

View File

@ -1,7 +1,7 @@
import axios from 'axios'
import type { ChunkingStrategy, QueryRequest, QueryResponse, QueryStreamEvent, IngestResponse, DocumentListResponse, ChunkInfo, DeleteResponse, PromptProfileListResponse, PromptSetResponse, PromptUpdateRequest, PromptBatchUpdateRequest, PromptActivateResponse, PromptStatusResponse, ProfileExportData, ProfileImportResponse, QueryHistoryList, QueryHistoryDetail, HistoryStats, HistoryDeleteResponse, FullTranscriptResponse, VideoUploadResponse } from '../types'
const BASE_URL: string = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:8000/api/v1'
const BASE_URL: string = import.meta.env.VITE_API_BASE_URL ?? '/api/v1'
export const apiClient = axios.create({ baseURL: BASE_URL })
@ -78,7 +78,7 @@ export const deleteChunk = async (chunkId: string): Promise<DeleteResponse> => {
}
export const getChunkPdfUrl = (filePath: string): string => {
const baseUrl: string = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:8000/api/v1'
const baseUrl: string = import.meta.env.VITE_API_BASE_URL ?? '/api/v1'
return `${baseUrl}/chunks/${encodeURIComponent(filePath)}/pdf`
}

View File

@ -265,7 +265,7 @@ describe('ResponsePanel', () => {
await waitFor(() => {
expect(mockFetch).toHaveBeenCalledTimes(1)
expect(mockFetch).toHaveBeenCalledWith(
'http://localhost:8000/api/v1/v2/highlights/batch',
'/api/v1/v2/highlights/batch',
expect.objectContaining({
method: 'POST',
headers: { 'Content-Type': 'application/json' },

View File

@ -61,7 +61,7 @@ export function processCitationsForSubq(
function buildCitationUrl(source: SourceMetadata, highlightReady?: boolean): string | null {
if (highlightReady && source.document_id && source.sub_question_text) {
const v2Base = `${import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:8000/api/v1'}/v2`
const v2Base = `${import.meta.env.VITE_API_BASE_URL ?? '/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) {