Replies: 1 comment
|
Hi, we hit exactly the same issue: Chrome/Chromium strips the port from the Origin header for loopback URLs ( We filed a bug report with the root cause and a suggested fix (compare hostname only, ignore the port): We also maintain a green "double-click to run" launcher distribution that already fixes this with an idempotent patch (Origin check changed to hostname comparison; in LAN mode it also merges the machine's LAN IPs into trustedHosts). Feel free to reference the approach or use it directly:
你好,我们遇到了完全一样的问题:Chrome/Chromium 对回环地址( 同时我们维护的绿色整合版启动器已经解决该问题(自动打幂等补丁:Origin 校验改 hostname 比较,局域网模式自动并入本机局域网 IP),欢迎参考方案或直接使用:
本回复由 AI 辅助撰写 / This reply was drafted with AI assistance. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
发现BUG后,deepseek v4 Flash 帮我修复了该 bug,并提交了如下讨论,正文内容为 AI 书写,它已将我本地代码修复了。报错截图如下:

大家好,我在当前 master(
0.1.0-rc.5,commit47f943859b)的 Web UI 上遇到了一个可稳定复现的 403。按贡献指引发到这里(目前仓库暂不接受外部 PR)。环境
pnpm run build)后以pnpm dsh web启动复现步骤
DEEPSEEK_API_KEY后运行pnpm dsh webhttp://127.0.0.1:3080transport failure for /api/host.pickDirectory: HTTP 403;点「重新选择」每次都复现因此 Chrome 下完全无法创建工作区。同源
curl(带Origin: http://127.0.0.1:3080)请求正常,掩盖了非浏览器客户端不会遇到该问题的事实。诊断
/api浏览器信任栅栏isTrustedApiRequest(packages/client/connection/src/api-request-trust.ts)要求附加的Origin与Host权威完全一致(new URL(origin).host === hostUrl.host)。通过临时在服务端加日志,实测 Chrome 请求头为:
Host: 127.0.0.1:3080Origin: http://127.0.0.1—— Chromium 剥掉了端口Sec-Fetch-Site: same-origin、Sec-Fetch-Mode: cors、Referer: http://127.0.0.1:3080/于是
new URL('http://127.0.0.1').host=127.0.0.1≠127.0.0.1:3080→ 在任何 RPC 分发之前返回 403。根因:Chromium 对回环/IP 来源的Origin头序列化时不带端口(Chrome 151 实测);因此按完整权威比较会拒绝所有发往 Web UI 的合法 Chromium 请求。解决思路(已本地实现并测试)
Origin的主机名与Host主机名精确比较;仅当Origin携带显式非默认端口时才比较端口:Origin(Chromium 的序列化方式)接受——浏览器根本没有发送端口可供比较。Origin必须与Host端口一致,从而为序列化完整来源的浏览器(如 Safari/Firefox)保留同主机跨端口 CSRF 防御。:80/:443)归一化为无端口。sec-fetch-site: cross-site仍拒绝、Host栅栏与trustedHosts语义不变;栅栏仍只是可达性策略,不是认证。需要说明的一个边界:在 Chromium 上,同一回环主机上不同端口的请求与同源请求无法区分,因为 Chromium 会完全省略
Origin里的端口——这是浏览器序列化的限制,不是栅栏能补的。测试覆盖:无端口接受、带端口匹配、跨端口拒绝、
https:默认端口归一化。如有需要可提供完整 diff。All reactions