web: fix error when showing error message of request

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-07-09 19:06:30 +02:00
parent 076e89b600
commit 7ddb459030
3 changed files with 6 additions and 3 deletions

View file

@ -7,7 +7,7 @@
"extract": "lingui extract", "extract": "lingui extract",
"build": "lingui compile && rollup -c ./rollup.config.js", "build": "lingui compile && rollup -c ./rollup.config.js",
"watch": "lingui compile && rollup -c -w", "watch": "lingui compile && rollup -c -w",
"lint": "eslint . --max-warnings 0", "lint": "eslint . --max-warnings 0 --fix",
"lit-analyse": "lit-analyzer src" "lit-analyse": "lit-analyzer src"
}, },
"lingui": { "lingui": {

View file

@ -10,7 +10,8 @@ export class LoggingMiddleware implements Middleware {
let msg = `authentik/api[${tenant.matchedDomain}]: `; let msg = `authentik/api[${tenant.matchedDomain}]: `;
msg += `${context.response.status} ${context.init.method} ${context.url}`; msg += `${context.response.status} ${context.init.method} ${context.url}`;
if (context.response.status >= 400) { if (context.response.status >= 400) {
context.response.text().then(t => { const resClone = context.response.clone();
resClone.text().then(t => {
msg += ` => ${t}`; msg += ` => ${t}`;
console.debug(msg); console.debug(msg);
}); });

View file

@ -37,7 +37,9 @@ export function configureSentry(canDoPpi: boolean = false): Promise<Config> {
if (response.status < 500) { if (response.status < 500) {
return null; return null;
} }
const body = await response.json(); // Need to clone the response, otherwise the .text() and .json() can't be re-used
const resCopy = response.clone();
const body = await resCopy.json();
event.message = `${response.status} ${response.url}: ${JSON.stringify(body)}` event.message = `${response.status} ${response.url}: ${JSON.stringify(body)}`
} }
if (event.exception) { if (event.exception) {