question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any way to allow only whitelisted requests? Or correct way to use setRequestInterceptionEnabled?

See original GitHub issue

The purpose is to allow only whitelisted HTTP requests. I’d like to pass any request to be made to a function and reject/stop any requested URLs that don’t match a simple RegEx.

CDP.version:

{
   "Browser": "HeadlessChrome/59.0.3071.104",
   "Protocol-Version": "1.2",
   "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/59.0.3071.104 Safari/537.36",
   "V8-Version": "5.9.211.35",
   "WebKit-Version": "537.36 (@1c037b7399035b4209e72455256615e8972493aa)"
}

Chrome-remote-interface: "chrome-remote-interface": "^0.23.2"

Have tried a couple of methods with dead ends:

  1. Using Network.setBlockedURLs({ urls: urlsList }) - good if you know blocking URLs in advance (not in my case).
  2. Using Network.requestWillBeSent. Are there any way to block request at this stage? It can easily extract the request information that is needed, but I haven’t found how I could stop the requests from continuing.
  3. Using Network.enableRequestInterception from chrome-remote-interface protocol file or Network.setRequestInterceptionEnabled from Chrome DevTools Protocol Viewer - latest (tip-of-tree) with no success and the same errors: Error: 'NetworkAgent.enableRequestInterception' wasn't found Error: 'Network.setRequestInterceptionEnabled' wasn't found Even tried sending the same command as a client.send(method, [params], [callback]) from the docs with no luck.

I’ve stumbled upon this Google Doc explaining that Interception are meant for Blocking and Modifying Network requests so probably the best way would be to use that one and I’m simply not aren’t using it correctly.

Could you specify an example on how to properly use request Interceptions?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cyrus-andcommented, Jul 11, 2017

Here it is, hope it helps.

0reactions
paambaaticommented, Jul 17, 2018

@paulirish Is there a public discussion that we can subscribe/bookmark/follow?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Request headers missing after page ... - GitHub
If I set page.setRequestInterceptionEnabled(true); some request headers disappear. Consider the following code: (async() => { const browser ...
Read more >
node.js - page.setRequestInterceptionEnabled(true) prevents ...
I'm trying to block some user preference & tracking related requests. The only other solution I could come up, without using ...
Read more >
Allow branch whitelist to override "Only build pull requests"
I'd like to enable “Only build pull requests” on a project as all feature branches are PR'ed to master and sent to a...
Read more >
How secure is github's whitelisting CORS domains?
The Github API allows you to make requests using CORS [1]. The CORS requests are only allowed by certain whitelisted domains : Any...
Read more >
What Is Whitelisting and How Do You Use It? - MakeUseOf
Best of all, they can be implemented for just about anything from emails, applications, IP addresses, and gaming servers. Let us explore the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found