github-community-projects / private-mirrors

A GitHub App that allows you to contribute upstream using private mirrors of public projects
MIT License
125 stars 13 forks source link

feat: Add Proxy Support #134

Closed riley-kohler closed 3 months ago

riley-kohler commented 3 months ago

Pull Request

Proposed Changes

This PR adds proxy support to ICF by configuring fetch/undici with a global dispatcher the uses proxy envs and older request libraries with a global agent that uses the envs as well.

This solution works but has a couple of remaining issues.

I wanted to put up this PR to get the "working" proxy support out there but am open to any suggestions or changes needed before merging.

Readiness Checklist

Author/Contributor

Reviewer

ajhenry commented 3 months ago

Thanks a ton for the contribution!!

I figured this might lead to some conflicts 😅 I’ll be happy to resolve them for you

ajhenry commented 3 months ago

Hey all, gonna be taking care of this in the next day or so! I'm going to remove scripts from the docker build step since the forwarder shouldn't be needed there.

@sutterj will be taking point on this 👑

riley-kohler commented 3 months ago

@sutterj saw your comment in my email but couldn't find it to reply directly. I switched the mjs to ts because I needed to import a ts file into both that mjs file and the rest of the ts code base and thought it would be necessary for compatibility. If it's not that's fine. I did notice some type issues when converting but it seems like they rooted back to incorrect types from the libraries that are being used and switching to tsx (which I needed to get it running at all) ignored the type issues for now.

sutterj commented 3 months ago

I'm looking into converting the project/tests to ESM to see if I can't solve this issue more elegantly, but I was able to get it to work by making a second version of the proxy as mjs and converting the webhooks relay back to mjs. Not the "ideal" solution, but it solves the types issues and allows us to go back to ts-node.

sutterj commented 3 months ago

@riley-kohler Can you pull the latest here and test it on your network?

riley-kohler commented 3 months ago

Just tested on our network and everything is still working