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

fix(http): use proxy agent setup that supports proxy env variables with no_proxy #781

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jontze
Copy link
Contributor

@jontze jontze commented Apr 22, 2024

Fixes a bug introduced in #762, where the "no-proxy" environment configuration was ignored.

With this PR I moved from the usage of https-proxy-agent to proxy-agent. This was done as https-proxy-agent was configured to take the proxy url from the environment but the library itself doesn't handle NO_PROXY / no_proxy configuration.

proxy-agent on the other side, is sitting on top of the https-proxy-agent and http-proxy-agent library and decides if the proxy is used based on the request URL and the domains specified in the "no proxy" environment variables.


To test this

  1. Set the configuration for your proxy in the usual environment variables HTTP_PROXY , HTTPS_PROXY, http_proxy, https_proxy, NO_PROXY, no_proxy.
  2. You can set your custom repository download url in the generator-cli.repository.downloadUrl config
  3. Append your domain to the no_proxy and NO_PROXY environment variables OR if you don't have a mirror at hand, just add the default domain specified in config.schema.json and ensure that you have a way to verify that the traffic went not through the proxy.
  4. Execute the generator

⚠️ Define both variables! If you only set the upper case NO_PROXY variable, the lower case one will have presence!

ℹ️ The downloaded jar will be cached near the dist files of the generator cli (so usually in you node_modules), beside you patched the version like this in your package.json of your project, then it's not in your node_modules:

  "@openapitools/openapi-generator-cli": "file:../openapi-generator-cli/dist/apps/generator-cli"

Related to OpenAPITools#762

In the linked PR, the proxy config was restored, but it didn't respected
the `NO_PROXY` | `no_proxy` configuration. This commit moved to a
different approach that is working with all common proxy environment
variables.
@jontze jontze force-pushed the fix/respect_no_proxy_in_proxy_setup branch from 7e31c2e to 69c9dc5 Compare April 24, 2024 17:31
@jontze jontze marked this pull request as ready for review April 24, 2024 17:32
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.

None yet

1 participant