0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(core): allow non-json body type when parsing (#6379)

This commit is contained in:
Gao Sun 2024-08-01 16:41:07 +08:00 committed by GitHub
parent b91ec0cd6f
commit 323a5650f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -400,10 +400,10 @@ export default function initOidc(
// 'application/json' for body parsing. Update relatively when we enable that feature.
if (ctx.is(jsonContentType)) {
ctx.headers['content-type'] = formUrlEncodedContentType;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
ctx.request.body = JSON.parse(body);
// eslint-disable-next-line no-restricted-syntax
ctx.request.body = trySafe(() => JSON.parse(body) as unknown);
} else if (ctx.is(formUrlEncodedContentType)) {
ctx.request.body = querystring.parse(body);
ctx.request.body = trySafe(() => querystring.parse(body));
}
}