Skip to content

fix: clear auth on 401 API responses#1152

Merged
theborakompanioni merged 3 commits intojoinmarket-webui:v2from
kunal-595:feat/api-401-auto-logout
Apr 12, 2026
Merged

fix: clear auth on 401 API responses#1152
theborakompanioni merged 3 commits intojoinmarket-webui:v2from
kunal-595:feat/api-401-auto-logout

Conversation

@kunal-595
Copy link
Copy Markdown
Contributor

Added a response interceptor that clears auth state and query cache when the backend returns 401. Previously stale tokens after laptop sleep or browser throttle left the UI in a broken state instead of redirecting to login.

Copilot AI review requested due to automatic review settings February 24, 2026 21:59
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 adds a response interceptor to handle 401 Unauthorized API responses by automatically clearing the authentication state and query cache. This prevents the UI from getting stuck in a broken state when tokens become stale (e.g., after laptop sleep or browser throttling), ensuring users are redirected to the login page.

Changes:

  • Added unauthorizedResponseInterceptor function that clears auth state and query cache on 401 responses
  • Registered the response interceptor in the API client setup
  • Imported queryClient from ./queryClient to enable cache clearing

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

Comment thread src/lib/config.ts Outdated
@theborakompanioni theborakompanioni merged commit 488c7a3 into joinmarket-webui:v2 Apr 12, 2026
3 checks passed
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.

3 participants