Skip to content

fix: disable automatic auth revalidation on auth pages#2213

Merged
gauthier-th merged 2 commits intodevelopfrom
fallenbagel/fix/unnecessary-auth-requests-on-login
Dec 9, 2025
Merged

fix: disable automatic auth revalidation on auth pages#2213
gauthier-th merged 2 commits intodevelopfrom
fallenbagel/fix/unnecessary-auth-requests-on-login

Conversation

@fallenbagel
Copy link
Copy Markdown
Collaborator

Description

Prevents unnecessary /api/v1/auth/me requests on login, setup, and password reset pages. These requests used to return 401/403 errors since no user would be logged in, spamming reverse proxy logs and triggering fail2ban rules for users running seerr behind reverse proxy/fail2ban setups.

This PR disables SWR's automatic revalidation (on mount, focus, and interval) when on auth pages, while keeping manual revalidation functional so login flow still works correctly.

How Has This Been Tested?

  • Monitored the network logs when on the above mentioned auth pages

Screenshots / Logs (if applicable)

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Prevents unnecessary `/api/v1/auth/me` requests on login, setup, and password reset pages.

fix #738
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses unnecessary API requests to /api/v1/auth/me on authentication pages by conditionally disabling SWR's automatic revalidation behaviors. The fix prevents 401/403 errors from spamming reverse proxy logs and triggering fail2ban rules when users visit login, setup, or password reset pages.

Key Changes:

  • Added Next.js router integration to detect auth pages via pathname matching
  • Conditionally disabled revalidateOnFocus, revalidateOnMount, and revalidateOnReconnect for auth pages
  • Preserved manual revalidation functionality to maintain proper login flow

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/hooks/useUser.ts Outdated
Comment thread src/hooks/useUser.ts Outdated
Copy link
Copy Markdown
Member

@gauthier-th gauthier-th left a comment

Choose a reason for hiding this comment

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

LGTM

@gauthier-th gauthier-th merged commit 1f04eeb into develop Dec 9, 2025
8 checks passed
@gauthier-th gauthier-th deleted the fallenbagel/fix/unnecessary-auth-requests-on-login branch December 9, 2025 12:17
fallenbagel added a commit that referenced this pull request Jan 10, 2026
Directly fetch and populate SWR cache with user data instead of relying on revalidate() which is
disabled on auth pages since #2213

fix #2288
gauthier-th pushed a commit that referenced this pull request Jan 11, 2026
Directly fetch and populate SWR cache with user data instead of relying on revalidate() which is
disabled on auth pages since #2213

fix #2288
0xSysR3ll pushed a commit to 0xSysR3ll/jellyseerr that referenced this pull request Jan 20, 2026
…-team#2290)

Directly fetch and populate SWR cache with user data instead of relying on revalidate() which is
disabled on auth pages since seerr-team#2213

fix seerr-team#2288
lucianchauvin pushed a commit to lucianchauvin/jellyseerr that referenced this pull request Apr 20, 2026
…-team#2290)

Directly fetch and populate SWR cache with user data instead of relying on revalidate() which is
disabled on auth pages since seerr-team#2213

fix seerr-team#2288
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.

GET /api/v1/auth/me before user login

4 participants