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

Remove http-network-proxy and use http-proxy-middleware directly #147

Merged
merged 9 commits into from
Mar 12, 2025

Conversation

triwav
Copy link
Owner

@triwav triwav commented Mar 7, 2025

No description provided.

return proxy;
this.server = this.app
// This lets us see the json body of the request in the proxy middleware
.use(express.json())
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if the response isn't json? Do we have other middleware to handle those? Does it also still proxy json requests?

Copy link
Owner Author

Choose a reason for hiding this comment

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

If it is not a json body then we do not have access to it. Theoretically someone could still get the body by adding observers on the req but just about all apis that you would want to inspect are json. In the future we could add more but json was all that we had before as well and never used anything else so we'll see if someone requests it.

Copy link
Contributor

Choose a reason for hiding this comment

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

So not even xml or plain text would funnel through?

Copy link
Owner Author

Choose a reason for hiding this comment

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

It isn't captured. If someone wanted to they could still read it off of req with some work but I would say that's not the common use case. I would say xml and form body would probably be the biggest things to add but all we use is json currently. If someone sees a need then we can look into it then.

* Below method is triggered by the middleware that helps us to overwrite the path.
*/
private rewritePath(path, req) {
const urlParts = url.parse(req.originalUrl.replace('/;', ''));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this semicolon the standard way of writing proxy URLs? Like is this how it works for charles as well? If not, it might be good to align on whatever "normal" proxy convention is out there (i don't know, haven't used them much).

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes correct that is how it is done in Charles as well.

const urlParts = url.parse(req.originalUrl.replace('/;', ''));
path = urlParts.path || path;

// If Charles proxy we want to use the original url instead
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this only apply to Charles proxy, or would it work for others? Might be good to clarify why we know there's already a proxy in the pipeline and can skip.

Copy link
Owner Author

Choose a reason for hiding this comment

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

It could be applied to other applications as well if they follow the same format as Chris details here https://github.com/chrisdp/Roku-Charles-example but Charles is the main one people use

Copy link
Contributor

@TwitchBronBron TwitchBronBron left a comment

Choose a reason for hiding this comment

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

Had a few questions, but otherwise looks pretty good

triwav and others added 3 commits March 10, 2025 17:00
…n NetworkProxy.start(). Add removeCallback function in processRequest and processResponse args to simplify cleanup
…av/roku-test-automation into remove_http-network-proxy_depedency
@triwav triwav merged commit 286d0b8 into master Mar 12, 2025
1 check passed
@triwav triwav deleted the remove_http-network-proxy_depedency branch March 12, 2025 17:54
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.

2 participants