Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Fix Playwright Content-Type Handling (#2040)

tomf52a37a9dda8
diff --git a/apps/playwright-service-ts/api.ts b/apps/playwright-service-ts/api.ts
index 3041d8ca3..a6613523f 100644
--- a/apps/playwright-service-ts/api.ts
+++ b/apps/playwright-service-ts/api.ts
@@ -141,8 +141,8 @@ const scrapePage = async (page: Page, url: string, waitUntil: 'load' | 'networki
let ct: string | undefined = undefined;
if (response) {
headers = await response.allHeaders();
- ct = Object.entries(headers).find(x => x[0].toLowerCase() === "content-type")?.[1];
- if (ct && (ct[1].includes("application/json") || ct[1].includes("text/plain"))) {
+ ct = Object.entries(headers).find(([key]) => key.toLowerCase() === "content-type")?.[1];
+ if (ct && (ct.toLowerCase().includes("application/json") || ct.toLowerCase().includes("text/plain"))) {
content = (await response.body()).toString("utf8"); // TODO: determine real encoding
}
}