Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why the method page.on('request') can't intercept fetch request #4695

Closed
zhaobingss opened this issue Jul 12, 2019 · 3 comments
Closed

why the method page.on('request') can't intercept fetch request #4695

zhaobingss opened this issue Jul 12, 2019 · 3 comments

Comments

@zhaobingss
Copy link

zhaobingss commented Jul 12, 2019

why the method page.on('request') can't intercept fetch request like this:
image
any one help

@LeMoussel
Copy link

LeMoussel commented Jul 12, 2019

Do you test with page.setRequestInterception() to intercept request?

Example :

const puppeteer = require('puppeteer');

(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage()
await page.setRequestInterception(true)
page.on('request', interceptedRequest => {
  // Do some stuff ...

  interceptedRequest.continue()
})

await page.goto('https://example.org/')

browser.close();
})();

@zhaobingss
Copy link
Author

zhaobingss commented Jul 12, 2019

@LeMoussel yes of course, other request is no problem except fetch

@aslushnikov
Copy link
Contributor

aslushnikov commented Jul 14, 2019

@zhaobingss fetch requests are intercepted just fine - when they come from the main page.

We don't yet surface network traffic from webworkers though; see #2781. And given the initiators on your screenshot, these fetches are coming from web workers.

(closing as a dupe of the workers network bug).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants