-
Notifications
You must be signed in to change notification settings - Fork 11
fix(serve): create an http agent that always use IPv4 #4589
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
next-core
|
||||||||||||||||||||||||||||
| Project |
next-core
|
| Branch Review |
steve/v3-fix-proxy
|
| Run status |
|
| Run duration | 00m 22s |
| Commit |
|
| Committer | Shenwei Wang |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
16
|
| View all changes introduced in this branch ↗︎ | |
|
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
packages/brick-container/serve/getProxy.jsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "@next-core/eslint-config-next" to extend from. Please check that the name of the config is correct. The config "@next-core/eslint-config-next" was referenced from the config file in "/.eslintrc". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. 概述步骤概述此更改主要修改了 变更
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/brick-container/serve/getProxy.js (1)
13-22: 建议在多种协议场景下充分考虑当前 Agent 的复用问题
getAgent函数只在全局变量agent未被定义时才会初始化。如果server在不同调用中可能从http变为https,此实现可能会导致后续请求复用已创建的 Agent 而非正确的协议栈。视使用场景而定,建议在需要时根据协议动态创建多个 Agent,或在逻辑上保证server不会随时改变协议。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/brick-container/serve/getProxy.js(4 hunks)
🔇 Additional comments (3)
packages/brick-container/serve/getProxy.js (3)
1-2: 引入 Node.js 原生模块以支持自定义 Agent 的 IPv4 功能
这两行导入node:http与node:https模块,为后面的自定义 IPv4 Agent 打下基础,没有明显问题。
87-91: 在 Host 为 0.0.0.0 的场景下强制重置 Origin 头部可以防止意外影响
这里新增了当服务器 Host 来源是0.0.0.0时强制更新 Origin 的逻辑,有助于统一请求头,避免代理层对本地等测试环境产生误判。此实现看起来逻辑合理。
479-479: 在代理选项中使用agent有助于一致地启用 IPv4
通过在返回值中配置agent属性,确保了在代理请求时默认使用 IPv4。若将来需要更多参数(如keepAlive等),可以进一步扩展此配置。
[approve]
依赖检查
组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。
请勾选以下两组选项其中之一:
或者:
提交信息检查
Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。
破坏性变更:
feat作为提交类型。BREAKING CHANGE: 你的变更说明。新特性:
feat作为提交类型。问题修复:
fix作为提交类型。杂项工作:
即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:
chore,docs,test等作为提交类型。Summary by CodeRabbit
新功能
性能改进
accept-encoding头部管理。