diff --git a/package.json b/package.json index ca4e3b1..be5e9fb 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.52.0", "playwright-lighthouse": "^4.0.0", "zod": "^3.23.8" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 16f06bc..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.50.1 - version: 1.50.1 + 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.50.1) + 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.50.1: - resolution: {integrity: sha512-ra9fsNWayuYumt+NiM069M6OkcRb1FZSK8bgi66AtpFoWkg2+y0bJSNmkFrWhMbEBbVKC/EruAHH3g0zmtwGmQ==} + 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.50.1: - resolution: {integrity: sha512-G8rwsOQJ63XG6BbKj2w5rHeavFjy5zynBA9zsJMMtBoe/Uf757oG12NXz6e6OirF7RCrTVAKFXbLmn1RbL7Qaw==} + 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.50.1: {} + playwright-core@1.52.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.52.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.52.0 - playwright@1.50.1: + playwright@1.52.0: dependencies: - playwright-core: 1.50.1 + playwright-core: 1.52.0 optionalDependencies: fsevents: 2.3.2 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; }),