HareshKannan
HareshKannan

Reputation: 103

Puppeteer redirect throws ERR_BLOCKED_BY_CLIENT

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.

Upvotes: 2

Views: 1773

Answers (1)

Mohit Mishra
Mohit Mishra

Reputation: 19

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.

Upvotes: 0

Related Questions