Fix EventSource URLs missing /ppt-tool basePath
Add apiUrl() helper to apiFetch.ts for non-fetch URL construction. Fixed 3 SSE streams: outlines, presentation, job progress. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6157fcbc4e
commit
910f58369c
4 changed files with 11 additions and 3 deletions
|
|
@ -23,6 +23,7 @@ import { toast } from "sonner";
|
|||
import { cn } from "@/lib/utils";
|
||||
import Wrapper from "@/components/Wrapper";
|
||||
import { WizardApi, JobStatus } from "../../services/api/wizard";
|
||||
import { apiUrl } from "@/lib/apiFetch";
|
||||
|
||||
export default function WizardProgressPage() {
|
||||
const router = useRouter();
|
||||
|
|
@ -52,7 +53,7 @@ export default function WizardProgressPage() {
|
|||
if (!jobId) return;
|
||||
|
||||
const connectSSE = () => {
|
||||
const es = new EventSource(`/api/v1/ppt/jobs/${jobId}/stream`);
|
||||
const es = new EventSource(apiUrl(`/api/v1/ppt/jobs/${jobId}/stream`));
|
||||
eventSourceRef.current = es;
|
||||
|
||||
es.addEventListener("response", (event) => {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { toast } from "sonner";
|
|||
import { setOutlines } from "@/store/slices/presentationGeneration";
|
||||
import { jsonrepair } from "jsonrepair";
|
||||
import { RootState } from "@/store/store";
|
||||
import { apiUrl } from "@/lib/apiFetch";
|
||||
|
||||
|
||||
|
||||
|
|
@ -29,7 +30,7 @@ export const useOutlineStreaming = (presentationId: string | null) => {
|
|||
setIsLoading(true)
|
||||
try {
|
||||
eventSource = new EventSource(
|
||||
`/api/v1/ppt/outlines/stream/${presentationId}`
|
||||
apiUrl(`/api/v1/ppt/outlines/stream/${presentationId}`)
|
||||
);
|
||||
|
||||
eventSource.addEventListener("response", (event) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { useEffect, useRef } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { apiUrl } from "@/lib/apiFetch";
|
||||
import {
|
||||
clearPresentationData,
|
||||
setPresentationData,
|
||||
|
|
@ -27,7 +28,7 @@ export const usePresentationStreaming = (
|
|||
dispatch(clearPresentationData());
|
||||
|
||||
eventSource = new EventSource(
|
||||
`/api/v1/ppt/presentation/stream/${presentationId}`
|
||||
apiUrl(`/api/v1/ppt/presentation/stream/${presentationId}`)
|
||||
);
|
||||
|
||||
eventSource.addEventListener("response", (event) => {
|
||||
|
|
|
|||
|
|
@ -11,3 +11,8 @@ export function apiFetch(path: string, init?: RequestInit): Promise<Response> {
|
|||
const url = path.startsWith('/api/') ? `${BASE_PATH}${path}` : path;
|
||||
return fetch(url, init);
|
||||
}
|
||||
|
||||
/** Returns the full URL with basePath — use for EventSource and other non-fetch calls. */
|
||||
export function apiUrl(path: string): string {
|
||||
return path.startsWith('/api/') ? `${BASE_PATH}${path}` : path;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue