DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

How to Get HTTP Request Headers in Puppeteer

Read Puppeteer’s outgoing request headers with a page request listener—no interception needed. Learn lowercase header lookup, extra headers, and interception pitfalls.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Listen for the page’s request event and call request.headers(). This reads outgoing request headers without enabling interception. In Puppeteer 25.12.0, the returned object uses lowercase header names, such as content-type.

Read headers from Puppeteer requests

Register the listener before navigating so it can observe the navigation request and subsequent page traffic:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();

  page.on('request', request => {
    console.log(request.url(), request.headers());
  });

  await page.goto('https://example.com');
} finally {
  await browser.close();
}

The callback receives an HTTPRequest. Its headers() method returns a record of header names and values associated with that outgoing request. The pattern works with the standard request events; passive logging does not require request interception. See the HTTPRequest.headers() reference and the network logging guide.

CommonJS version

If your project uses CommonJS, replace the import with const puppeteer = require('puppeteer');. Keep the same listener and navigation pattern.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read a particular header

Header names in the returned object are lowercase, so use lowercase keys when accessing them:

page.on('request', request => {
  const headers = request.headers();
  console.log(headers['content-type']);
});

HTTP header names are case-insensitive on the wire, but JavaScript object property names are not. Looking up headers['Content-Type'] will not match a returned content-type key.

Request headers versus response headers

request.headers() describes headers associated with an outgoing request from the page. To inspect information sent back by a server, listen for the response event and use the response API instead. Puppeteer’s request and response events are distinct; choose based on which direction of traffic you mean.

HTTP status errors are not necessarily network failures: a request receiving a 404 or 503 is still treated as completed and emits requestfinished, not requestfailed solely because of that status. Redirects finish one request and create a new request for the redirected URL. These distinctions matter when correlating logged headers with outcomes. See the HTTPRequest class reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do you need request interception?

No, not to observe headers. Puppeteer emits page network events by default. Use the simple request listener for logging or inspection.

Interception is for controlling requests—for example, changing headers for selected requests, fulfilling a request yourself, or aborting it. Once interception is enabled, every intercepted request stalls until a handler continues it, responds to it, or aborts it. A logging-only interception handler that forgets to resolve requests can prevent page activity from completing.

await page.setRequestInterception(true);
page.on('request', request => {
  console.log(request.headers());
  request.continue();
});

When multiple handlers or packages may resolve a request, check request.isInterceptResolutionHandled() before calling continue(), abort(), or respond(). If your handler awaits something before acting, check again afterward: another handler may have resolved the request in the meantime. Duplicate resolution can raise an exception. See the request interception guide.

Add headers to requests

Use a page-wide header when it applies everywhere

To add a common header to every request initiated by one page, call page.setExtraHTTPHeaders() before navigation:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
The SQL Programming Language: .
  • Used Book in Good Condition
await page.setExtraHTTPHeaders({
  'x-client-tag': 'example',
});

page.on('request', request => {
  console.log(request.headers()['x-client-tag']);
});

await page.goto('https://example.com');

The method accepts a string-to-string record and returns a promise. Header names are lowercased, and Puppeteer does not guarantee the order in which headers are sent. Consult the Page.setExtraHTTPHeaders() reference.

Use interception for request-specific changes

For different values on selected requests, use interception and pass header overrides to request.continue(). This gives per-request control, but also means every intercepted request must be resolved. Prefer the page-wide method when the same extra header belongs on all requests.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

  • A header looks missing: confirm the listener is on the request event and inspect the lowercase property key, such as headers['content-type'].
  • You enabled interception just to log: disable it and use the ordinary request listener. If interception is needed for another reason, ensure every request path continues, responds, or aborts.
  • The page hangs after enabling interception: a request may be left unresolved, or multiple handlers may be trying to resolve it. Resolve each request and use isInterceptResolutionHandled() where handlers can overlap.
  • You meant server response metadata: inspect the response event rather than outgoing request headers.
  • A 404 or 503 appears as finished rather than failed: that is expected for an HTTP error status; Puppeteer distinguishes an HTTP response from a transport-level request failure.

Or skip the browser setup

If your goal is to capture a rendered page rather than inspect Puppeteer’s outgoing headers, ScreenshotNeo offers a one-request screenshot API. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers indicating the page verdict and billing status. Its MCP server provides screenshot, page-info, and PDF-capture tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for 1,000 free screenshots a month, with no card required.

Frequently Asked Questions

Which Puppeteer version is this API guidance for?

The cited API references identify themselves as Puppeteer 25.12.0; check the live documentation if using a substantially newer version.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.