From 1b63e461cce20830845b12931cb3912af085860c Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 3 Apr 2021 23:06:57 +0200 Subject: [PATCH] web/api: log requests to console Signed-off-by: Jens Langhammer --- web/src/api/Config.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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(), ], });