From 17be8cf6b09d298c45e1ba140f1776397634a353 Mon Sep 17 00:00:00 2001 From: Unmesh100 Date: Mon, 25 May 2026 14:10:44 +0530 Subject: [PATCH 1/2] Removed Duplicate API calls and Hardcoded test user data --- app/routes/home.tsx | 16 ++++++++++++++-- app/routes/projects.tsx | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/routes/home.tsx b/app/routes/home.tsx index 831860c..9ff8d71 100644 --- a/app/routes/home.tsx +++ b/app/routes/home.tsx @@ -1,5 +1,9 @@ import React, { useRef, useEffect, useCallback, useState } from "react"; import type { PlayerRef, CallbackListener } from "@remotion/player"; +import { redirect, useLoaderData, type LoaderFunctionArgs } from "react-router"; +import axios from "axios"; +import { requireUser } from "~/utils/auth.server"; +import type { PlayerRef, CallbackListener } from "@remotion/player"; import { Play, Pause, @@ -59,7 +63,15 @@ interface Message { timestamp: Date; } + +export async function loader({ request }: LoaderFunctionArgs) { + const res = await requireUser(request); + if (res.status !== 200) throw redirect("/login"); + return { user: res.data }; +} + export default function TimelineEditor() { + const { user } = useLoaderData(); const containerRef = useRef(null); const playerRef = useRef(null); const fileInputRef = useRef(null); @@ -338,7 +350,7 @@ export default function TimelineEditor() { } const timelineState = getTimelineState(); - await axios.put(`/ai/api/api/projects/${encodeURIComponent(id)}`, timelineState, { + await axios.put(`/ai/api/projects/${encodeURIComponent(id)}`, timelineState, { withCredentials: true, }); @@ -756,7 +768,7 @@ export default function TimelineEditor() { {}} /> diff --git a/app/routes/projects.tsx b/app/routes/projects.tsx index 3098b8b..f01e272 100644 --- a/app/routes/projects.tsx +++ b/app/routes/projects.tsx @@ -58,7 +58,7 @@ export async function loader({ request }: LoaderFunctionArgs) { if (res.status !== 200) throw redirect("/login"); const { origin } = new URL(request.url); - const projectsRes = await axios.get<{ projects: Project[] }>(`${origin}/ai/api/api/projects`, { + const projectsRes = await axios.get<{ projects: Project[] }>(`${origin}/ai/api/projects`, { headers: { Cookie: request.headers.get("Cookie") }, }); From d1ef97de7e3fc5f59496e46c26431f6987756591 Mon Sep 17 00:00:00 2001 From: Unmesh100 Date: Mon, 25 May 2026 14:13:23 +0530 Subject: [PATCH 2/2] Removed duplicate imports in home.tsx for cleaner code --- app/routes/home.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/routes/home.tsx b/app/routes/home.tsx index 9ff8d71..ea1bed7 100644 --- a/app/routes/home.tsx +++ b/app/routes/home.tsx @@ -3,7 +3,6 @@ import type { PlayerRef, CallbackListener } from "@remotion/player"; import { redirect, useLoaderData, type LoaderFunctionArgs } from "react-router"; import axios from "axios"; import { requireUser } from "~/utils/auth.server"; -import type { PlayerRef, CallbackListener } from "@remotion/player"; import { Play, Pause, @@ -35,7 +34,6 @@ import { Switch } from "~/components/ui/switch"; import { Label } from "~/components/ui/label"; import { Input } from "~/components/ui/input"; import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from "~/components/ui/resizable"; -import axios from "axios"; import { toast } from "sonner"; // Hooks