mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5974] [Question]: 为什么 POST /panel/api/clients/update/{email} 把 email 放在 URL 路径里而不是请求体 #4139
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4139
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @zhaotao-ui on GitHub (Jul 15, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5974
Describe the bug
POST /panel/api/clients/update/{email} 啥她嘛玩意?
一个post接口,把参数放url里,是不是有啥毛病啊,你会不会写啊
How to reproduce the problem
1
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.5.0
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
centos
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@zhaotao-ui commented on GitHub (Jul 15, 2026):
一个改client的操作,前后居然调用10个api,这么设计,也是个人才
@github-actions[bot] commented on GitHub (Jul 15, 2026):
这不是缺陷,是预期设计:URL 路径里的
{email}只是用来定位要更新哪个客户端的资源标识符,真正要修改的字段仍然是通过 POST 请求体以 JSON 形式发送的,并没有被塞进 URL。已在源码中确认(对应你所使用的
v3.5.0版本):internal/web/controller/client.go:56:g.POST("/update/:email", a.update)internal/web/controller/client.go:159-167:先用c.Param("email")从路径取出标识符,再用c.ShouldBindJSON(&updated)从请求体解析要更新的totalGB、expiryTime、enable、flow等字段。frontend/src/hooks/useClients.ts:324-328:client对象整体作为 JSON body 发送;拼接进 URL 前email会先经过encodeURIComponent转义,邮箱里出现的特殊字符不会破坏路由匹配。frontend/src/pages/api-docs/endpoints.ts:596-605也写明:email是路径参数(当前客户端的唯一标识),body 是完整的 client JSON payload(整行替换,不是增量 patch)。这也是整个 clients API 的统一约定,不是这一个接口的例外:
/add、/update/:email、/del/:email、/:email/attach、/:email/detach等所有写操作路由(internal/web/controller/client.go:47-83)都是把资源标识符放在路径里、主体数据放在 body 里,统一用 POST 提交。这与不少主流 REST 风格 API 的做法类似(例如 Stripe 的POST /v1/customers/{id}):路径定位资源,body 承载改动内容。严格 REST 语义下整行替换更常见的是用PUT,但用 POST 承载写操作是该项目一贯的接口风格选择,不是实现错误。如果你实际遇到的是某个具体请求失败(例如邮箱包含特殊字符导致 404/500,或返回了非预期的错误信息),麻烦补充:
email等敏感信息可以打码);success/msg字段);本次报告未包含可复现的具体故障现象,先按设计说明处理关闭;如有新的复现信息欢迎在此评论或重新打开。
This reply was generated automatically; a maintainer may follow up.