fix(frontend): check both 'auth_token' and 'token' in api client
Unblocks API calls by correctly reading the token saved by auth.ts
This commit is contained in:
parent
41d7d9ee70
commit
c1650fd1a4
1 changed files with 2 additions and 1 deletions
|
|
@ -16,7 +16,8 @@ function logCrudAction(action: string, entity: string, details?: any) {
|
|||
* Generic API Request Wrapper
|
||||
*/
|
||||
async function apiRequest<T>(endpoint: string, options: RequestInit = {}): Promise<T> {
|
||||
const token = localStorage.getItem("token");
|
||||
// Token can be stored as 'auth_token' (from auth.ts login) or 'token' (legacy)
|
||||
const token = localStorage.getItem("auth_token") || localStorage.getItem("token");
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||
|
|
|
|||
Loading…
Reference in a new issue