fix: replace nested Routes with useLocation, remove pushState+reload, add debug logs

- ProfileRoutes: removed nested <Routes> in favor of useLocation()/useNavigate()
  with strict allowlist for /profile/me and /profile/me/edit
- ProfileComponentWrapper: replaced pushState()+reload() with navigate()
- useApi: log 401 and non-401 errors
- contexts.tsx: log fetchCurrentUser lifecycle and auth:unauthorized events
- axios.ts: log auth server 401s
This commit is contained in:
2026-07-19 18:12:48 +05:30
parent 77db5e1f05
commit 4cabe0be0c
4 changed files with 103 additions and 51 deletions

View File

@@ -17,7 +17,9 @@ export function attachAuthInterceptors(client: AxiosInstance) {
(res) => res,
(error) => {
if (error.response?.status === 401) {
console.log("[authAxios] 401 from %s %s", error.config?.method, error.config?.url);
tokenStore.clear();
window.dispatchEvent(new CustomEvent("auth:unauthorized"));
}
return Promise.reject(error);
}