Skip to content

fix: use router navigation on token refresh failure #79

Description

@EmeditWeb

Problem

In api.ts (lines 61, 78-80), when token refresh fails, the code uses window.location.href = '/' which causes a full page reload and loses all React state.

Root Cause

The redirect was implemented before React Router was fully integrated.

What To Build

  1. Import and use React Router's navigate function instead
  2. Or trigger a Zustand state reset that the router guard picks up
  3. Also call clearTokens() from the store so Zustand state stays in sync

Files To Touch

  • src/services/api.ts — lines 61, 78-80 replace hard redirect

Acceptance Criteria

  • No full page reload on token refresh failure
  • User redirected to /dashboard
  • All store state cleared before redirect
  • Axios interceptor still rejects the original request

Mandatory Checks

  • context/ files read
  • npm run build passes
  • PR references this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions