Skip to content

Commit

Permalink
restore local request blocking to puppeteer
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Mar 28, 2021
1 parent 13838b4 commit 3ac1de2
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions packages/cli/src/lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,19 @@ class BrowserRunner {

await page.setRequestInterception(true);

// only allow puppeteer to load necessary scripts needed for pre-rendering of the site itself
// only allow puppeteer to load necessary (local) scripts needed for pre-rendering of the site itself
page.on('request', interceptedRequest => {
// const interceptedRequestUrl = interceptedRequest.url();

// console.debug('request', interceptedRequestUrl);
// TODO handle serialize only requests
interceptedRequest.continue();
// if (
// interceptedRequestUrl.indexOf('bundle.js') >= 0 || // webpack bundles, webcomponents-bundle.js
// interceptedRequestUrl === requestUrl || // pages / routes
// interceptedRequestUrl.indexOf('localhost:4000') >= 0 // Apollo GraphQL server
// ) {
// interceptedRequest.continue();
// } else {
// console.debug('aborting request', interceptedRequestUrl)
// interceptedRequest.abort();
// }
const interceptedRequestUrl = interceptedRequest.url();

if (
interceptedRequestUrl.indexOf('http://127.0.0.1') >= 0 ||
interceptedRequestUrl.indexOf('localhost') >= 0
) {
interceptedRequest.continue();
} else {
// console.warn('aborting request', interceptedRequestUrl);
interceptedRequest.abort();
}
});

try {
Expand Down

0 comments on commit 3ac1de2

Please sign in to comment.