feat(web): generated OpenAPI types + typed openapi-fetch client with 401 redirect

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-03 22:25:10 +02:00
parent 5267f05089
commit dcfddc88c7
5 changed files with 1438 additions and 22 deletions
+7
View File
@@ -0,0 +1,7 @@
/** Hard-navigate to login. Isolated so it can be spied/mocked in tests and swapped
* for a router navigation if needed. */
export function redirectToLogin(): void {
if (window.location.pathname !== "/login") {
window.location.assign("/login");
}
}
+18
View File
@@ -0,0 +1,18 @@
import createClient, { type Middleware } from "openapi-fetch";
import type { paths } from "./schema";
import { redirectToLogin } from "./auth-redirect";
const onUnauthorized: Middleware = {
async onResponse({ response }) {
if (response.status === 401) {
redirectToLogin();
}
return response;
},
};
export const api = createClient<paths>({ credentials: "include" });
api.use(onUnauthorized);
+1232
View File
File diff suppressed because it is too large Load Diff