ProtectedheadersProtectedoptionsProtectedurlsStaticoriginalOptionalinit: RequestInitOptionalinit: RequestInitOptionalinit: RequestInitStaticoriginalSets the request method, request URL, and synchronous flag.
Throws a "SyntaxError" DOMException if either method is not a valid method or url cannot be parsed.
Throws a "SecurityError" DOMException if method is a case-insensitive match for CONNECT, TRACE, or TRACK.
Throws an "InvalidAccessError" DOMException if async is false, current global object is a Window object, and the timeout attribute is not zero or the responseType attribute is not the empty string.
Optionalusername: string | nullOptionalpassword: string | nullOptionaloptions: Partial<InterceptorOptions>Optionaloptions: Partial<InterceptorOptions>ProtectedapplyOptional_options: Partial<InterceptorOptions>ProtectedapplyConditionally applies matchRules, rewriteRules, publicDirectoryPath, and responseFixturesPath headers from the matching InterceptorUrl when the request URL matches a pattern with these options set.
OptionalinterceptorUrl: InterceptorUrlProtectedclearProtecteddecorateProtecteddecorateProtectedfilterFilters out the overwrite record order header after the first request to each URL pattern.
The overwrite header (RECORD_ORDER and OVERWRITE_ID) should only be sent once per URL pattern in this.urls, not once per actual request URL. This method mutates the urlsToVisit array to track which patterns have already been visited.
Implementation notes:
Pattern matching:
Lifecycle safety:
Example: this.urls = [{ pattern: //api/.+/ }, { pattern: 'https://example.com/exact' }]
Request 1 to /api/users - matches first pattern, removes from urlsToVisit, includes headers Request 2 to /api/posts - pattern already removed, omits overwrite headers Request 3 to exact URL - matches second pattern, removes from urlsToVisit, includes headers Request 4 to exact URL - pattern already removed, omits overwrite headers
The headers object to potentially modify
The URL or URL pattern being requested (actual URL for fetch/XHR, pattern for Playwright/Cypress)
Mutable array of URL patterns that haven't been visited yet
ProtectednormalizeProtectedrestoreOptionalmode: InterceptModeOptionalorder: RecordOrderOptionalpolicy: RecordPolicyOptionalstrategy: RecordStrategyOptionalkey: stringOptionalname: stringOptionalsessionId: stringOptionaltitle: string
MDN Reference