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();
}
}
- My initial HTML page load happens properly with the redirect URL.
- 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,
I am still new to puppeteer and chrome extension development, kindly let me know if any way to figure out the issue here.