feat: add JWT refresh token support with automatic token renewal and session expiration handling
CI / backend (push) Failing after 3s
CI / frontend (push) Failing after 26s

Add /auth/refresh endpoint to issue new access tokens using refresh tokens with token type validation and user activity checks, implement automatic token refresh on 401 responses with single retry logic in frontend API client, add authorizedFetch helper for non-JSON endpoints with refresh support, store both access and refresh tokens in localStorage with clearTokens cleanup helper, add nexafabric.authExpired event
This commit is contained in:
2026-07-09 14:27:46 +02:00
parent 7818158a9b
commit 45baa6ae7a
4 changed files with 95 additions and 10 deletions
+2 -4
View File
@@ -2,7 +2,7 @@ import { FormEvent, useState } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { Database, Download, Plus } from "lucide-react";
import { api, IpAddress, Network, Subnet, token } from "../api/client";
import { api, authorizedFetch, IpAddress, Network, Subnet } from "../api/client";
import { DataTable } from "../components/DataTable";
import { buttonClass, Field, inputClass, secondaryButtonClass, selectClass } from "../components/FormControls";
import { Modal } from "../components/Modal";
@@ -49,9 +49,7 @@ export function Ipam() {
}
async function exportCsv() {
const response = await fetch("/api/v1/ipam/export.csv", {
headers: token() ? { Authorization: `Bearer ${token()}` } : {},
});
const response = await authorizedFetch("/ipam/export.csv");
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const link = document.createElement("a");