[GH-ISSUE #5974] [Question]: 为什么 POST /panel/api/clients/update/{email} 把 email 放在 URL 路径里而不是请求体 #4139

Closed
opened 2026-10-31 20:37:28 +07:00 by bsakaguchi · 2 comments
Owner

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

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
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 ```shell ``` ### 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 - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:37:28 +07:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@zhaotao-ui commented on GitHub (Jul 15, 2026):

一个改client的操作,前后居然调用10个api,这么设计,也是个人才

<!-- gh-comment-id:4982424548 --> @zhaotao-ui commented on GitHub (Jul 15, 2026): 一个改client的操作,前后居然调用10个api,这么设计,也是个人才
Author
Owner

@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)
  • Handler 实现 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,或返回了非预期的错误信息),麻烦补充:

  1. 完整请求 URL 和请求体(email 等敏感信息可以打码);
  2. 返回的 HTTP 状态码和响应内容(success/msg 字段);
  3. 面板日志中对应的报错。

本次报告未包含可复现的具体故障现象,先按设计说明处理关闭;如有新的复现信息欢迎在此评论或重新打开。

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4982427923 --> @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)` - Handler 实现 `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,或返回了非预期的错误信息),麻烦补充: 1. 完整请求 URL 和请求体(`email` 等敏感信息可以打码); 2. 返回的 HTTP 状态码和响应内容(`success`/`msg` 字段); 3. 面板日志中对应的报错。 本次报告未包含可复现的具体故障现象,先按设计说明处理关闭;如有新的复现信息欢迎在此评论或重新打开。 *This reply was generated automatically; a maintainer may follow up.*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4139
No description provided.