refresh() unconditionally calls apiFetch<Me>('/users/me') on mount, regardless of whether a token exists in localStorage. For anyone browsing public pages (home, marketplace, about, security) without logging in, this fires a network request that is guaranteed to be unauthenticated/fail, wasting a round trip on every load.
Suggested fix: At the top of refresh, check for a stored token; if there isn't one, call setUser(null) directly and return without calling apiFetch.
refresh()unconditionally callsapiFetch<Me>('/users/me')on mount, regardless of whether a token exists inlocalStorage. For anyone browsing public pages (home, marketplace, about, security) without logging in, this fires a network request that is guaranteed to be unauthenticated/fail, wasting a round trip on every load.Suggested fix: At the top of
refresh, check for a stored token; if there isn't one, callsetUser(null)directly and return without callingapiFetch.