Devr.AI icon indicating copy to clipboard operation
Devr.AI copied to clipboard

BUG: Silent 401 handling does not redirect user to login

Open muhammadtihame opened this issue 9 months ago • 2 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

What happened?

📌 Issue Overview

When an API request returns a 401 Unauthorized response, the frontend only logs an error in the console and does not provide any visible feedback or redirect to the login page.


🔍 Current Behavior

  • Axios interceptor catches 401
  • Console logs "Unauthorized request"
  • User remains on the same page
  • UI appears broken (data not loading, buttons failing)
  • No redirection or session reset occurs

✅ Expected Behavior

  • On a definitive 401 response:
    • Clear authentication/session state
    • Redirect user to /login
    • OR display a clear “Session expired” message

🧪 Steps to Reproduce

  1. Login normally
  2. Expire the token manually or clear auth storage
  3. Trigger any protected API call (dashboard, analytics, etc.)
  4. Observe that console logs error but no redirect or UI feedback occurs

🎯 Impact

This affects production readiness and user experience.

When sessions expire:

  • Users experience broken UI behavior
  • No guidance is provided
  • App appears unstable

💡 Suggested Direction

In the Axios response interceptor:

  • Trigger a global logout (Supabase signOut or equivalent)
  • Redirect to /login
  • Optionally show a “Session expired” notification

Record

  • [x] I agree to follow this project's Code of Conduct
  • [x] I want to work on this issue

muhammadtihame avatar Feb 21 '26 06:02 muhammadtihame

Hi @Zahnentferner 👋

I can work on improving the 401 handling in the Axios interceptor and implement proper session clearing and redirect to /login.

Please let me know if this issue is assigned or open for contribution.

mahek2016 avatar Feb 21 '26 09:02 mahek2016

Hi @Zahnentferner 👋

I can work on improving the 401 handling in the Axios interceptor and implement proper session clearing and redirect to /login.

Please let me know if this issue is assigned or open for contribution.

Thanks for picking this up 👋

Happy to collaborate if needed.
Let me know if you'd like help validating edge cases or testing the fix.

muhammadtihame avatar Feb 22 '26 18:02 muhammadtihame