Skip to content

Commit 3bf230e

Browse files
fix: Handle 401 response parsing correctly in userInfo endpoint
1 parent f63fd8c commit 3bf230e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/core/services/HttpClient.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,14 @@ export class HttpClient {
9696
// No Content
9797
json = {};
9898
} else {
99+
// Read text first to avoid body-already-consumed errors when JSON parsing fails
100+
const text = await response.text();
99101
try {
100-
json = await response.json();
102+
json = JSON.parse(text);
101103
} catch {
102104
json = {
103105
error: 'invalid_json',
104-
error_description: await response.text(),
106+
error_description: text,
105107
};
106108
}
107109
}

0 commit comments

Comments
 (0)