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:
parent
a54d688867
commit
67d2bddeb6
|
|
@ -7,7 +7,7 @@ import { getPdfViewerUrl } from '../lib/api'
|
||||||
import { processCitations, processCitationsForSubq, extractCitedSources, highlightTerms } from '../utils/citationParser'
|
import { processCitations, processCitationsForSubq, extractCitedSources, highlightTerms } from '../utils/citationParser'
|
||||||
import { bulletizeMarkdown } 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 {
|
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)}`
|
return `${V2_BASE}/highlights?document_id=${encodeURIComponent(document_id)}&chunk_index=${chunk_index}&sub_question=${encodeURIComponent(sub_question)}`
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ export function useFullTranscript({ videoId }: UseFullTranscriptOptions) {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
setError(null)
|
setError(null)
|
||||||
try {
|
try {
|
||||||
const base = import.meta.env.VITE_API_BASE_URL ?? ''
|
const base = import.meta.env.VITE_API_BASE_URL ?? '/api/v1'
|
||||||
const resp = await fetch(`${base}/api/v1/video/${videoId}/transcribe`, {
|
const resp = await fetch(`${base}/video/${videoId}/transcribe`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
})
|
})
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import axios from 'axios'
|
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'
|
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 })
|
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 => {
|
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`
|
return `${baseUrl}/chunks/${encodeURIComponent(filePath)}/pdf`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ describe('ResponsePanel', () => {
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(mockFetch).toHaveBeenCalledTimes(1)
|
expect(mockFetch).toHaveBeenCalledTimes(1)
|
||||||
expect(mockFetch).toHaveBeenCalledWith(
|
expect(mockFetch).toHaveBeenCalledWith(
|
||||||
'http://localhost:8000/api/v1/v2/highlights/batch',
|
'/api/v1/v2/highlights/batch',
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ 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) {
|
||||||
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)}`
|
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) {
|
if (source.chunk_file_path) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue