0

I am using puppeteer to bring up chromium and launch a page. For my scenario the page URL has to be intercepted along with the css/js/img requests coming from the page.

My puppeteer code for page interception looks like this,

await page.setRequestInterception(true);
page.on("request", async (request: HTTPRequest) => {
  if (request.url().endsWith(".html") || 
      request.url().endsWith(".js") || 
      request.url().endsWith(".css") ||
      request.url().endsWith(".png")) {
    let redirectUrl = await getNewUrl(request.url());
    request.continue({ url: redirectUrl });
  } else {
    request.continue();
  }
}
  1. My initial HTML page load happens properly with the redirect URL.
  2. Then the HTML page has a few browser requests the redirect URL is also fetched and the request is continued with redirect URL.

All the browser requests return an error looking like this, enter image description here

I am still new to puppeteer and chrome extension development, kindly let me know if any way to figure out the issue here.

HareshKannan
  • 83
  • 11
  • 1
    Usually `ERR_BLOCKED_BY_CLIENT` comes when your resource is blocked by a Chrome extension. Are you sure the URL is correct and can you check by disabling extensions? – Sachin Jain Feb 01 '22 at 10:07
  • The URL is correct and verified it. If I copy the URL of the `thumb.png` that you see in the screenshot above and run it on the same page, the redirection happens properly and the image(from the redirected URL) comes up with no issues. – HareshKannan Feb 01 '22 at 10:54
  • Do you mind joining [this slack channel](https://requestlycommunity.slack.com/join/shared_invite/zt-113lursq9-2TI4bXLhkdNPEpTUJBprIA#/shared-invite/email) I'd be interested in seeing this over a call and helping you debug it? We can coordinate on slack about the meeting time. – Sachin Jain Feb 01 '22 at 15:11

1 Answers1

0

I am also suffering from same issue but I have a solution for this issue. If you are using ajax method and give static url path so remove this path and fix from dynamic path.

  • Hi Mohit are you still having suffer from this `Puppeteer` redirect throwing `ERR_BLOCK_BY_CLIENT`? Or does this solution make this go away. Regardless can you please provide more information to your answer? Ideally a code sample that includes your solution with some comments to what it's doing. Thanks o:) – treckstar Jul 24 '22 at 03:59