From 433d5cba5277b44bcd895058245fb9b63d034ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 22 Apr 2025 15:37:56 +0200 Subject: [PATCH 1/3] Fix flutter support --- package.json | 2 +- pnpm-lock.yaml | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index ca4e3b1..aa0ed75 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "dependencies": { "h3": "^1.13.0", "lighthouse": "^12.2.1", - "playwright": "^1.50.1", + "playwright": "^1.51.0", "playwright-lighthouse": "^4.0.0", "zod": "^3.23.8" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 16f06bc..51eb99e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,11 +15,11 @@ importers: specifier: ^12.2.1 version: 12.2.1 playwright: - specifier: ^1.50.1 - version: 1.50.1 + specifier: ^1.51.0 + version: 1.51.0 playwright-lighthouse: specifier: ^4.0.0 - version: 4.0.0(lighthouse@12.2.1)(playwright-core@1.50.1) + version: 4.0.0(lighthouse@12.2.1)(playwright-core@1.51.0) zod: specifier: ^3.23.8 version: 3.23.8 @@ -777,8 +777,8 @@ packages: pend@1.2.0: resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==} - playwright-core@1.50.1: - resolution: {integrity: sha512-ra9fsNWayuYumt+NiM069M6OkcRb1FZSK8bgi66AtpFoWkg2+y0bJSNmkFrWhMbEBbVKC/EruAHH3g0zmtwGmQ==} + playwright-core@1.51.0: + resolution: {integrity: sha512-x47yPE3Zwhlil7wlNU/iktF7t2r/URR3VLbH6EknJd/04Qc/PSJ0EY3CMXipmglLG+zyRxW6HNo2EGbKLHPWMg==} engines: {node: '>=18'} hasBin: true @@ -792,8 +792,8 @@ packages: playwright-core: optional: true - playwright@1.50.1: - resolution: {integrity: sha512-G8rwsOQJ63XG6BbKj2w5rHeavFjy5zynBA9zsJMMtBoe/Uf757oG12NXz6e6OirF7RCrTVAKFXbLmn1RbL7Qaw==} + playwright@1.51.0: + resolution: {integrity: sha512-442pTfGM0xxfCYxuBa/Pu6B2OqxqqaYq39JS8QDMGThUvIOCd6s0ANDog3uwA0cHavVlnTQzGCN7Id2YekDSXA==} engines: {node: '>=18'} hasBin: true @@ -1843,19 +1843,19 @@ snapshots: pend@1.2.0: {} - playwright-core@1.50.1: {} + playwright-core@1.51.0: {} - playwright-lighthouse@4.0.0(lighthouse@12.2.1)(playwright-core@1.50.1): + playwright-lighthouse@4.0.0(lighthouse@12.2.1)(playwright-core@1.51.0): dependencies: chalk: 4.1.2 lighthouse: 12.2.1 ua-parser-js: 1.0.39 optionalDependencies: - playwright-core: 1.50.1 + playwright-core: 1.51.0 - playwright@1.50.1: + playwright@1.51.0: dependencies: - playwright-core: 1.50.1 + playwright-core: 1.51.0 optionalDependencies: fsevents: 2.3.2 From 749df3dbbda7c1bfb972111dc0ba80ec27173636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 22 Apr 2025 15:47:08 +0200 Subject: [PATCH 2/3] Upgrade playwright --- package.json | 2 +- pnpm-lock.yaml | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index aa0ed75..be5e9fb 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "dependencies": { "h3": "^1.13.0", "lighthouse": "^12.2.1", - "playwright": "^1.51.0", + "playwright": "^1.52.0", "playwright-lighthouse": "^4.0.0", "zod": "^3.23.8" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 51eb99e..509e63e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,11 +15,11 @@ importers: specifier: ^12.2.1 version: 12.2.1 playwright: - specifier: ^1.51.0 - version: 1.51.0 + specifier: ^1.52.0 + version: 1.52.0 playwright-lighthouse: specifier: ^4.0.0 - version: 4.0.0(lighthouse@12.2.1)(playwright-core@1.51.0) + version: 4.0.0(lighthouse@12.2.1)(playwright-core@1.52.0) zod: specifier: ^3.23.8 version: 3.23.8 @@ -777,8 +777,8 @@ packages: pend@1.2.0: resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==} - playwright-core@1.51.0: - resolution: {integrity: sha512-x47yPE3Zwhlil7wlNU/iktF7t2r/URR3VLbH6EknJd/04Qc/PSJ0EY3CMXipmglLG+zyRxW6HNo2EGbKLHPWMg==} + playwright-core@1.52.0: + resolution: {integrity: sha512-l2osTgLXSMeuLZOML9qYODUQoPPnUsKsb5/P6LJ2e6uPKXUdPK5WYhN4z03G+YNbWmGDY4YENauNu4ZKczreHg==} engines: {node: '>=18'} hasBin: true @@ -792,8 +792,8 @@ packages: playwright-core: optional: true - playwright@1.51.0: - resolution: {integrity: sha512-442pTfGM0xxfCYxuBa/Pu6B2OqxqqaYq39JS8QDMGThUvIOCd6s0ANDog3uwA0cHavVlnTQzGCN7Id2YekDSXA==} + playwright@1.52.0: + resolution: {integrity: sha512-JAwMNMBlxJ2oD1kce4KPtMkDeKGHQstdpFPcPH3maElAXon/QZeTvtsfXmTMRyO9TslfoYOXkSsvao2nE1ilTw==} engines: {node: '>=18'} hasBin: true @@ -1843,19 +1843,19 @@ snapshots: pend@1.2.0: {} - playwright-core@1.51.0: {} + playwright-core@1.52.0: {} - playwright-lighthouse@4.0.0(lighthouse@12.2.1)(playwright-core@1.51.0): + playwright-lighthouse@4.0.0(lighthouse@12.2.1)(playwright-core@1.52.0): dependencies: chalk: 4.1.2 lighthouse: 12.2.1 ua-parser-js: 1.0.39 optionalDependencies: - playwright-core: 1.51.0 + playwright-core: 1.52.0 - playwright@1.51.0: + playwright@1.52.0: dependencies: - playwright-core: 1.51.0 + playwright-core: 1.52.0 optionalDependencies: fsevents: 2.3.2 From bedf4b1371379a016ef4e620efaed43f3f28715f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 23 Apr 2025 15:47:58 +0200 Subject: [PATCH 3/3] Fix external CORS --- src/index.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 6d11ad6..fcdf15e 100644 --- a/src/index.js +++ b/src/index.js @@ -46,9 +46,27 @@ router.post( const context = await browser.newContext({ ...defaultContext, colorScheme: body.theme, - extraHTTPHeaders: body.headers, }); + + // await context.tracing.start({ screenshots: true, snapshots: true }); + const page = await context.newPage(); + + // Override headers + await page.route("**/*", async (route, request) => { + const url = request.url(); + if (url.startsWith("http://appwrite/")) { + return await route.continue({ + headers: { + ...request.headers(), + ...body.headers, + }, + }); + } + + return await route.continue({ headers: request.headers() }); + }); + await page.goto(body.url, { waitUntil: "domcontentloaded", }); @@ -58,6 +76,9 @@ router.post( } const screen = await page.screenshot(); + + // await context.tracing.stop({ path: '/tmp/trace' + Date.now() + '.zip' }); + await context.close(); return screen; }),