Skip to content

Commit 60f004a

Browse files
authored
Set custom User-Agent string for Puppeteer as workaround (projectwallace#35)
1 parent 534b42c commit 60f004a

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

_chromium.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ exports.extractCss = async url => {
1212
})
1313
const page = await browser.newPage()
1414

15+
// Set an explicit UserAgent, because the default UserAgent string includes something like
16+
// `HeadlessChrome/88.0.4298.0` and some websites/CDN's block that with a HTTP 403
17+
await page.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:85.0) Gecko/20100101 Firefox/85.0')
18+
1519
// Start CSS coverage. This is the meat and bones of this module
1620
await page.coverage.startCSSCoverage().catch(() => {})
1721

readme.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ The folks from [CSS Stats](https://cssstats.com/) have created [get-css](https:/
1414

1515
This package uses an actual browser under the hood to get all the CSS and exposes an HTTP endpoint that accepts a url to get the CSS from.
1616

17-
## Local testing
18-
19-
I have no idea how local testing for Now is supposed to work, so I created a tiny HTTP server in `dev.js` that calls the actual function that gets deployed.
20-
Run `ENV=dev npm run dev` to run a local version of the function for local testing.
21-
2217
## Credits
2318

2419
- This repo is pretty much an exact copy of [this example from Zeit](https://github.com/zeit/now-examples/tree/master/puppeteer-screenshot).

0 commit comments

Comments
 (0)