diff --git a/web/src/api/Config.ts b/web/src/api/Config.ts index 71dba42a0..7c222c345 100644 --- a/web/src/api/Config.ts +++ b/web/src/api/Config.ts @@ -2,11 +2,19 @@ import * as Sentry from "@sentry/browser"; import { Integrations } from "@sentry/tracing"; import { VERSION } from "../constants"; import { SentryIgnoredError } from "../common/errors"; -import { Config, Configuration, RootApi } from "authentik-api"; +import { Config, Configuration, Middleware, ResponseContext, RootApi } from "authentik-api"; import { getCookie } from "../utils"; import { API_DRAWER_MIDDLEWARE } from "../elements/notifications/APIDrawer"; import { MessageMiddleware } from "../elements/messages/Middleware"; +export class LoggingMiddleware implements Middleware { + + post(context: ResponseContext): Promise { + console.debug(`authentik/api: ${context.init.method} ${context.url} => ${context.response.status}`); + return Promise.resolve(context.response); + } +} + export const DEFAULT_CONFIG = new Configuration({ basePath: "/api/v2beta", headers: { @@ -16,6 +24,7 @@ export const DEFAULT_CONFIG = new Configuration({ middleware: [ API_DRAWER_MIDDLEWARE, new MessageMiddleware(), + new LoggingMiddleware(), ], });