mirror of
https://github.com/moghtech/komodo.git
synced 2026-05-06 00:18:38 -05:00
[PR #842] [MERGED] Fix unnecessary auth queries flooding console on login page #1789
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/moghtech/komodo/pull/842
Author: @MP-Tool
Created: 9/12/2025
Status: ✅ Merged
Merged: 9/12/2025
Merged by: @mbecker20
Base:
1.19.4← Head:fix/unnecessary-auth-api-queries📝 Commits (4)
dfbf006Refactor authentication error handling to use serror::Result and status codese23d193Enable user query only when JWT is present07e0380Enable query execution in useRead only if JWT is present6855f3eRevert backend auth changes - keep PR focused on frontend only📊 Changes
1 file changed (+7 additions, -0 deletions)
View changed files
📝
frontend/src/lib/hooks.ts(+7 -0)📄 Description
Problem:
After implementing the improved HTTP status codes in the previous PR #841, I noticed that the frontend was still making unnecessary API calls when users weren't logged in. Every time someone visits the login page or any protected route without authentication, the frontend automatically tries to fetch user data and core info, resulting in a bunch of 400/401 errors flooding the browser console.
This isn't just annoying for developers - it also means we're hitting the backend with pointless requests that we know will fail. The main culprits were:
useUser()hook fetching/auth/GetUsereven without JWT tokensuseRead()hook fetching/read/GetCoreInfoand other resources without authenticationSolution:
I've added authentication guards to the main query hooks to prevent these unnecessary API calls:
The fix uses React Query's
enabledoption to conditionally run queries:This means:
The changes are backward compatible and don't break any existing functionality - they just prevent queries from running when they're guaranteed to fail anyway.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.