title: How to Block data:image/encoded image requests through puppeteer
body: <p>I am trying to block all media in puppeteer that includes encoded images, so far I was successful until I hit data:image type. they are not being blocked in puppeteer.</p>
  <p>I tried many things like checking the url if it contains data:image, but still that request is not being aborted.</p>
  <p>Here's my current code</p>
  <pre><code>await page.setRequestInterception(true);
  page.on('request', (request) =&gt; {
      try{
          if (['image', 'media', 'png', 'jpeg', 'webp'].indexOf(request.resourceType()) !== -1) {
              request.abort();
          } else if(request.url().startsWith('data:image')) {
              request.abort();
          } else {
              request.continue();
          }
      } catch(e){
          errors.push({
              message: &quot;Interception Error&quot;,
              error_stack: e,
          });
      }
  });
  </code></pre>
  <p>Tried this as well</p>
  <pre><code>if(request.url().startsWith('data:image')) {
      request.respond({
          ok: statusMessage === &quot;OK&quot;,
          status: 200,
          body: '',
      });
  }
  </code></pre>
  <p>This code is blocking normal images fine, but not being able to block base64 encoded images.
  Here are some screenshots</p>
  <p><a href="https://i.stack.imgur.com/TSTGP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TSTGP.jpg" alt="Blocking images with specific format" /></a></p>
  <p><a href="https://i.stack.imgur.com/0a1tk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0a1tk.jpg" alt="Allowing data:image to be served from memory" /></a></p>