Skip to content

Commit 5125900

Browse files
fix: add content-type check for non-JSON responses in HttpClient
2 parents 0c03956 + 5756ebd commit 5125900

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 (content-type: ${contentType || 'unknown'})`);
74+
}
7175
return response.json();
7276
}
7377
}

0 commit comments

Comments
 (0)