Skip to content

Commit 3ac1de2

Browse files
restore local request blocking to puppeteer
1 parent 13838b4 commit 3ac1de2

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

packages/cli/src/lib/browser.js

+12-16
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,19 @@ class BrowserRunner {
3636

3737
await page.setRequestInterception(true);
3838

39-
// only allow puppeteer to load necessary scripts needed for pre-rendering of the site itself
39+
// only allow puppeteer to load necessary (local) scripts needed for pre-rendering of the site itself
4040
page.on('request', interceptedRequest => {
41-
// const interceptedRequestUrl = interceptedRequest.url();
42-
43-
// console.debug('request', interceptedRequestUrl);
44-
// TODO handle serialize only requests
45-
interceptedRequest.continue();
46-
// if (
47-
// interceptedRequestUrl.indexOf('bundle.js') >= 0 || // webpack bundles, webcomponents-bundle.js
48-
// interceptedRequestUrl === requestUrl || // pages / routes
49-
// interceptedRequestUrl.indexOf('localhost:4000') >= 0 // Apollo GraphQL server
50-
// ) {
51-
// interceptedRequest.continue();
52-
// } else {
53-
// console.debug('aborting request', interceptedRequestUrl)
54-
// interceptedRequest.abort();
55-
// }
41+
const interceptedRequestUrl = interceptedRequest.url();
42+
43+
if (
44+
interceptedRequestUrl.indexOf('http://127.0.0.1') >= 0 ||
45+
interceptedRequestUrl.indexOf('localhost') >= 0
46+
) {
47+
interceptedRequest.continue();
48+
} else {
49+
// console.warn('aborting request', interceptedRequestUrl);
50+
interceptedRequest.abort();
51+
}
5652
});
5753

5854
try {

0 commit comments

Comments
 (0)