Skip to content

Commit 93463a9

Browse files
Pavan-MicrosoftCopilot
andcommitted
fix: add content-type check for non-JSON responses in HttpClient
Co-authored-by: Copilot <copilot@github.com>
1 parent 0c03956 commit 93463a9

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/App/src/utils/httpClient.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class HttpClient {
6868
if (!response.ok) {
6969
throw new Error(`${config.method || 'GET'} ${url} failed: ${response.statusText}`);
7070
}
71+
const contentType = response.headers.get('content-type') || '';
72+
if (!contentType.toLowerCase().includes('application/json')) {
73+
throw new Error(`${config.method || 'GET'} ${url} returned non-JSON response`);
74+
}
7175
return response.json();
7276
}
7377
}

0 commit comments

Comments
 (0)