Skip to content

fix: use backend proxy for remote AgentKit to avoid CORS#584

Merged
yaozheng-fang merged 1 commit into
volcengine:mainfrom
FirstayZheng:fix/agentkit-cors
Jun 5, 2026
Merged

fix: use backend proxy for remote AgentKit to avoid CORS#584
yaozheng-fang merged 1 commit into
volcengine:mainfrom
FirstayZheng:fix/agentkit-cors

Conversation

@FirstayZheng
Copy link
Copy Markdown
Contributor

Summary

  • 添加后端代理路由 /agentkit-proxy/* 解决远程 AgentKit 跨域问题
  • 移除转发时的 CORS 相关 headers(origin, referer, sec-fetch-*)
  • 前端通过代理访问远程 AgentKit,本地智能体不受影响

根因

浏览器直接请求远程 AgentKit 时,CORS 策略阻止跨域访问,返回 403 Forbidden。

修复

参考 Skill Hub 代理实现,添加后端代理转发远程请求,移除浏览器特有 headers。

测试

  • ✅ 远程 AgentKit 连接成功创建会话和发消息
  • ✅ 本地智能体功能正常(回归测试通过)
  • ✅ Pre-commit 检查通过

- Add /agentkit-proxy/* route in backend (similar to skillhub proxy)
- Remove CORS-related headers (origin, referer, sec-fetch-*) before forwarding
- Frontend routes remote AgentKit requests through proxy via X-AgentKit-Base/Key headers
- Local agents continue to use same-origin requests (no impact)

Fixes 403 Forbidden error when connecting to remote AgentKit APIs

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@yaozheng-fang yaozheng-fang merged commit 15c2b89 into volcengine:main Jun 5, 2026
5 checks passed
@FirstayZheng FirstayZheng deleted the fix/agentkit-cors branch June 5, 2026 09:27
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