Skip to content

IFetchRequestHeaders

David Ortner edited this page Sep 23, 2025 · 2 revisions

IFetchRequestHeaders represents custom request headers for fetch requests matching specific URLs.

Signature

interface IFetchRequestHeaders

Example

import { Browser } from "happy-dom";

const browser = new Browser({
    fetch: {
        requestHeaders: [
            {
                url: /^https:\/\/example.com\/[a-z]{2}\/[a-z]{2}\/,
                headers: {
                    'X-Custom-Header': 'CustomValue'
                }
            }
        ]
    }
});

Properties

Property Type Description
url? string | RegExp | null URL to match. Matches all if not set.
headers Record<string, string> Request headers.

Clone this wiki locally