Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(proxy): support cookieDomainRewrite and cookiePathRewrite #313

Merged
merged 3 commits into from
Feb 16, 2023

Conversation

enkot
Copy link
Contributor

@enkot enkot commented Feb 5, 2023

Resolves #283

This PR adds new cookieDomainRewrite and cookiePathRewrite options to sendProxy and proxyRequest utilities.
The api is the the same as http-proxy.
To rewrite the domain we can use string:

proxyRequest('https://example.com', {
  cookieDomainRewrite: "somecompany.co.uk"
})

or mapper object:

proxyRequest('https://example.com', {
  // f.e. keep one domain unchanged, rewrite one domain and remove other domains
  cookieDomainRewrite: {
    "example.com": "example.com",
    "example.com": "somecompany.co.uk",
    "*": "",
  }
})

The same works for cookiePathRewrite.

@pi0 pi0 changed the title feat: add cookieDomainRewrite and cookiePathRewrite to proxy utils feat(proxy): support cookieDomainRewrite and cookiePathRewrite Feb 8, 2023
@codecov
Copy link

codecov bot commented Feb 8, 2023

Codecov Report

Merging #313 (a450d8f) into main (e5bfd2f) will increase coverage by 2.74%.
The diff coverage is 95.91%.

@@            Coverage Diff             @@
##             main     #313      +/-   ##
==========================================
+ Coverage   71.92%   74.66%   +2.74%     
==========================================
  Files          23       26       +3     
  Lines        2066     2333     +267     
  Branches      303      367      +64     
==========================================
+ Hits         1486     1742     +256     
- Misses        580      591      +11     
Impacted Files Coverage Δ
src/utils/cors/handler.ts 55.00% <55.00%> (ø)
src/utils/proxy.ts 81.52% <95.34%> (+4.05%) ⬆️
src/utils/cors/index.ts 100.00% <100.00%> (ø)
src/utils/cors/utils.ts 100.00% <100.00%> (ø)
src/utils/index.ts 100.00% <100.00%> (ø)
src/utils/internal/cookies.ts 97.43% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pi0 pi0 merged commit 3495dbe into unjs:main Feb 16, 2023
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.

Add cookieDomainRewrite, cookiePathRewrite options to sendProxy and proxyRequest
2 participants