web/common: make API errors more prominent in developer tools (#6637)
* web/common: make API errors more common in developer tools Signed-off-by: Jens Langhammer <jens@goauthentik.io> * web: default to origin for API urls, this also makes urls in logs clickable Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
599f7e7c88
commit
15e872762a
|
@ -63,7 +63,7 @@ export function getMetaContent(key: string): string {
|
|||
}
|
||||
|
||||
export const DEFAULT_CONFIG = new Configuration({
|
||||
basePath: process.env.AK_API_BASE_PATH + "/api/v3",
|
||||
basePath: (process.env.AK_API_BASE_PATH || window.location.origin) + "/api/v3",
|
||||
headers: {
|
||||
"sentry-trace": getMetaContent("sentry-trace"),
|
||||
},
|
||||
|
|
|
@ -25,8 +25,13 @@ export class LoggingMiddleware implements Middleware {
|
|||
|
||||
post(context: ResponseContext): Promise<Response | void> {
|
||||
let msg = `authentik/api[${this.tenant.matchedDomain}]: `;
|
||||
msg += `${context.response.status} ${context.init.method} ${context.url}`;
|
||||
console.debug(msg);
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/console#styling_console_output
|
||||
msg += `%c${context.response.status}%c ${context.init.method} ${context.url}`;
|
||||
let style = "";
|
||||
if (context.response.status >= 400) {
|
||||
style = "color: red; font-weight: bold;";
|
||||
}
|
||||
console.debug(msg, style, "");
|
||||
return Promise.resolve(context.response);
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue