Skip to content

Removed Duplicate API calls and Hardcoded test user data#186

Open
Unmesh100 wants to merge 2 commits into
trykimu:mainfrom
Unmesh100:main
Open

Removed Duplicate API calls and Hardcoded test user data#186
Unmesh100 wants to merge 2 commits into
trykimu:mainfrom
Unmesh100:main

Conversation

@Unmesh100
Copy link
Copy Markdown

Bug #1 — Duplicate /api/api/ in projects list API call

  • File: app/routes/projects.tsx:61
  • Issue: The axios GET call used ${origin}/ai/api/api/projects. The backend API router already has prefix /api, so this path resulted in a 404.
  • Fix: Changed to ${origin}/ai/api/projects

Bug #2 — Duplicate /api/api/ in timeline save API call

  • File: app/routes/home.tsx:341
  • Issue: Same path duplication — axios.put('/ai/api/api/projects/...') — causing save operations to fail with 404.
  • Fix: Changed to /ai/api/projects/...

Bug #3 — Hardcoded test user instead of real user data

  • File: app/routes/home.tsx:759
  • Issue: The ProfileMenu component received hardcoded fake data (name: "test", email: "test@test.com") instead of the actual logged-in user from
    the session.
  • Fix: Added a loader function that calls requireUser(request), returns the user, and redirects to /login on failure. The component now uses
    useLoaderData to get real user data (user.name, user.email, user.avatar_url).

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request integrates user authentication into the home route by adding a loader that fetches user data and replaces hardcoded profile information with dynamic values. It also corrects several API endpoint paths by removing redundant '/api' segments. Feedback was provided regarding the loader's error handling, suggesting that it should specifically check for 401 status codes for redirects while allowing other errors to be handled by an ErrorBoundary.

Comment thread app/routes/home.tsx

export async function loader({ request }: LoaderFunctionArgs) {
const res = await requireUser(request);
if (res.status !== 200) throw redirect("/login");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Redirecting to /login for any non-200 status code might be misleading if the server returns a 500 error. It is better to only redirect on 401 (Unauthorized) and handle other errors (like 500) by allowing the loader to throw an error that can be caught by an ErrorBoundary.

Suggested change
if (res.status !== 200) throw redirect("/login");
if (res.status === 401) throw redirect("/login");
if (res.status !== 200) throw new Response("Failed to load user data", { status: res.status });

@robinroy03
Copy link
Copy Markdown
Member

he is not a maintainer in this repo @Unmesh100
also we are migrating from a different branch https://github.com/trykimu/videoeditor/tree/feat/rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants