Skip to content

Add redirect option to strip headers on redirect#5281

Open
mcollina wants to merge 3 commits intomainfrom
add-redirect-strip-headers-option
Open

Add redirect option to strip headers on redirect#5281
mcollina wants to merge 3 commits intomainfrom
add-redirect-strip-headers-option

Conversation

@mcollina
Copy link
Copy Markdown
Member

@mcollina mcollina commented May 11, 2026

This relates to...

N/A

Rationale

Allow callers using the redirect interceptor to remove selected custom request headers before a redirected request is dispatched, with support for both all redirects and cross-origin redirects only.

Changes

Features

  • Add stripHeadersOnRedirect to the redirect interceptor options.
  • Add stripHeadersOnCrossOriginRedirect to strip selected headers only when redirecting across origins.
  • Apply configured header stripping during redirect request header cleanup.
  • Add type definitions, docs, and tests for the new options.

Bug Fixes

  • Import the node:test after hook in test/parser-issues.js so the current main test additions pass lint and CI.

Breaking Changes and Deprecations

N/A

Status

Tests

  • npx borp --timeout 180000 -p "test/interceptors/redirect.js"
  • npx borp --timeout 180000 -p "test/parser-issues.js"
  • npx tsd --files test/types/redirect-interceptor.test-d.ts
  • npx eslint lib/interceptor/redirect.js lib/handler/redirect-handler.js test/interceptors/redirect.js
  • npx eslint test/parser-issues.js lib/interceptor/redirect.js lib/handler/redirect-handler.js test/interceptors/redirect.js

@mcollina mcollina force-pushed the add-redirect-strip-headers-option branch from f1276f0 to d8cb0d1 Compare May 11, 2026 07:43
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 11, 2026

Codecov Report

❌ Patch coverage is 89.74359% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.25%. Comparing base (13f6af6) to head (48d84f7).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
lib/handler/redirect-handler.js 88.88% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5281      +/-   ##
==========================================
- Coverage   93.26%   93.25%   -0.01%     
==========================================
  Files         110      110              
  Lines       36533    36558      +25     
==========================================
+ Hits        34071    34092      +21     
- Misses       2462     2466       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants