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

Please reflect the request changes in the CallContext with the createCall function #109

Closed
1 task
yumaishida opened this issue Jun 26, 2023 · 1 comment
Closed
1 task
Labels
enhancement New feature or request

Comments

@yumaishida
Copy link

Describe the feature

I think the createCall function generates an IncomingMessage (request) from the CallContext and executes the handle function passed as the argument of the createCall function.

If the URL or header of the IncomingMessage (request) is changed in this handle function, would it be possible to add a process to reflect those changes in the CallContext after the handle function is executed?

Background

I am implementing an edge proxy library based on unjs/h3 that performs authentication and authorization for static websites running in various edge environments that run in front of CDNs, such as AWS Lambda@Edge (Viewer Request trigger), with reference to unjs/nitro. In an edge environment running in front of a CDN, I believe there is a use case for making changes to the original request and delegating the request to a subsequent process (the CDN's content return process).

We would like to implement a process to change the URL of the original request or to change the header in the edge proxy process, but if we use the createCall function of unjs/unenv as is, there is currently no way to know if the request has been changed within the handle function passed as an argument. It would be great if the createCall function could reflect changes in the CallContext (we are currently implementing such a process on our own).

Additional information

  • Would you be willing to help implement this feature?
@yumaishida yumaishida changed the title Please reflect the request changes in the CallContext with the createCall function. Please reflect the request changes in the CallContext with the createCall function Jun 29, 2023
@Hebilicious Hebilicious added the enhancement New feature or request label Jul 1, 2023 — with Volta.net
@pi0
Copy link
Member

pi0 commented Aug 2, 2023

Hi dear @yumaishida I think it makes sense to be able to have the same functionality but probably directly in h3.

Please check latest PRs particularly on 1.8 RC. New global hooks allow you to intercept latest status of event (modified path, headers, etc (unjs/h3#482) and also we are introducing direct plain and web adapters (unjs/h3#483).

Please let me know what you think, feel free to open issues in unjs/h3 if you have any ideas or questions or ping me to reopen if still belive we could land something in unenv too.

@pi0 pi0 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants