feat: update API endpoints to use FastAPI URL for streaming in outline and presentation components

This commit is contained in:
sudipnext 2026-03-23 19:38:57 +05:45
parent a31f2a0c15
commit 93ef13604a
4 changed files with 20 additions and 4 deletions

View file

@ -4,6 +4,7 @@ import { toast } from "sonner";
import { setOutlines } from "@/store/slices/presentationGeneration";
import { jsonrepair } from "jsonrepair";
import { RootState } from "@/store/store";
import { getFastAPIUrl } from "@/utils/api";
@ -28,9 +29,7 @@ export const useOutlineStreaming = (presentationId: string | null) => {
setIsStreaming(true)
setIsLoading(true)
try {
eventSource = new EventSource(
`/api/v1/ppt/outlines/stream/${presentationId}`
);
eventSource = new EventSource(`${getFastAPIUrl()}/api/v1/ppt/outlines/stream/${presentationId}`) ;
eventSource.addEventListener("response", (event) => {
const data = JSON.parse(event.data);

View file

@ -10,6 +10,7 @@ import { trackEvent, MixpanelEvent } from "@/utils/mixpanel";
import { AlertCircle } from "lucide-react";
import { setPresentationData } from "@/store/slices/presentationGeneration";
import { DashboardApi } from "../services/api/dashboard";
import { setupImageUrlConverter } from "@/utils/image-url-converter";
import { V1ContentRender } from "../components/V1ContentRender";
@ -43,6 +44,13 @@ const PresentationPage = ({ presentation_id }: { presentation_id: string }) => {
}
}
}, [presentationData]);
// Ensure /app_data and /static image paths resolve through FastAPI in Electron.
useEffect(() => {
const observer = setupImageUrlConverter();
return () => observer?.disconnect();
}, []);
// Function to fetch the slides
useEffect(() => {
fetchUserSlides();

View file

@ -16,8 +16,10 @@ import {
usePresentationNavigation,
useAutoSave,
} from "../hooks";
import { useEffect } from "react";
import { PresentationPageProps } from "../types";
import LoadingState from "./LoadingState";
import { setupImageUrlConverter } from "@/utils/image-url-converter";
import { usePresentationUndoRedo } from "../hooks/PresentationUndoRedo";
import PresentationHeader from "./PresentationHeader";
@ -32,6 +34,12 @@ const PresentationPage: React.FC<PresentationPageProps> = ({
const [isFullscreen, setIsFullscreen] = useState(false);
const [error, setError] = useState(false);
// Ensure /app_data and /static image paths resolve through FastAPI in Electron.
useEffect(() => {
const observer = setupImageUrlConverter();
return () => observer?.disconnect();
}, []);
const { presentationData, isStreaming } = useSelector(
(state: RootState) => state.presentationGeneration

View file

@ -8,6 +8,7 @@ import {
import { jsonrepair } from "jsonrepair";
import { toast } from "sonner";
import { MixpanelEvent, trackEvent } from "@/utils/mixpanel";
import {getFastAPIUrl} from "@/utils/api";
export const usePresentationStreaming = (
presentationId: string,
@ -30,7 +31,7 @@ export const usePresentationStreaming = (
trackEvent(MixpanelEvent.Presentation_Stream_API_Call);
eventSource = new EventSource(
`/api/v1/ppt/presentation/stream/${presentationId}`
`${getFastAPIUrl()}/api/v1/ppt/presentation/stream/${presentationId}`
);
eventSource.addEventListener("response", (event) => {