-
Notifications
You must be signed in to change notification settings - Fork 179
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 onResponse
callback
#368
Conversation
@pi0 Can we merge this one? It doesn't make any breaking change. |
src/utils/proxy.ts
Outdated
@@ -105,6 +106,10 @@ export async function sendProxy( | |||
event.node.res.setHeader(key, value); | |||
} | |||
|
|||
if (opts.onResponse) { | |||
await opts.onResponse(event); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be also nice to pass over the actual response
as second argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done!
Codecov Report
@@ Coverage Diff @@
## main #368 +/- ##
==========================================
+ Coverage 74.80% 74.85% +0.05%
==========================================
Files 26 26
Lines 2409 2414 +5
Branches 383 385 +2
==========================================
+ Hits 1802 1807 +5
Misses 607 607
|
Hi @pi0, |
Waiting for merge! This feature could potentially help to fix unjs/nitro#1237 and #376 |
Resolves #354
This PR adds
onResponse
callback tosendProxy
andproxyRequest
utilities.It accepts proxy
event
as argument which can be used to modify the response headers, cookies etc.:It can also be async: