Skip to content

fix: enable proxy support via environment variables in aiohttp#1465

Closed
Br1an67 wants to merge 1 commit intoMoonshotAI:mainfrom
Br1an67:fix/aiohttp-proxy-trust-env
Closed

fix: enable proxy support via environment variables in aiohttp#1465
Br1an67 wants to merge 1 commit intoMoonshotAI:mainfrom
Br1an67:fix/aiohttp-proxy-trust-env

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 17, 2026

Problem

aiohttp.ClientSession does not read HTTP_PROXY/HTTPS_PROXY/ALL_PROXY environment variables by default (trust_env defaults to False). Users behind corporate proxies cannot use kimi-cli.

Fix

Set trust_env=True in new_client_session() (utils/aiohttp.py).

Fixes #1234


Open with Devin

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

aiohttp.ClientSession does not read HTTP_PROXY/HTTPS_PROXY
environment variables by default. Set trust_env=True so that
users behind corporate proxies can use kimi-cli without issues.

Fixes MoonshotAI#1234
@Br1an67 Br1an67 force-pushed the fix/aiohttp-proxy-trust-env branch from a1b2bc1 to 11a1f98 Compare March 17, 2026 07:19
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11a1f984b6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

return aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=_ssl_context))
return aiohttp.ClientSession(
connector=aiohttp.TCPConnector(ssl=_ssl_context),
trust_env=True,

Choose a reason for hiding this comment

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

P2 Badge Avoid proxying loopback requests by default

Setting trust_env=True on the shared new_client_session() makes every HTTP call honor HTTP_PROXY/HTTPS_PROXY, which also affects loopback URLs unless the user has correctly set NO_PROXY. In environments with a proxy configured but no loopback bypass, requests to http://localhost/127.0.0.1 (for example via the web fetch tooling) are now routed to the proxy and fail, whereas they worked before this change. This introduces a regression for local-service workflows; proxy use should be limited to non-loopback targets or explicitly bypass loopback hosts.

Useful? React with 👍 / 👎.

@Br1an67
Copy link
Author

Br1an67 commented Mar 17, 2026

Closing in favor of #1236 which was submitted earlier and includes changelog + documentation updates.

@Br1an67 Br1an67 closed this Mar 17, 2026
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.

Environment variable based proxy is not working due to aiohttp default settings when using kimi login

1 participant