fix(browser): probe embed signals via GET fallback when HEAD omits them - #69
Open
trinhthiminh650-tech wants to merge 2 commits into
Open
Conversation
Some servers (e.g. aliyun consoles) answer HEAD without the X-Frame-Options / Content-Security-Policy headers that only their GET response carries. The embeddability probe then wrongly reported the site as embeddable, leaving the plain iframe to surface the browser's misleading "refused to connect" error (the site actually forbids framing via frame-ancestors). Retry once as GET when both embed signals are absent (the body is discarded — only headers matter), mirroring the existing 405/501 HEAD fallback. The client then shows the friendly embed-refusal panel with an "open in browser" action instead of the misleading connection error.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Add a side-card preference 'browserAllowedLoopback' (comma-separated host or host:port entries) that lets the sidebar browser navigate to explicitly trusted loopback addresses. Bare hosts (localhost, 127.0.0.1) match every port; host:port entries match exactly. Allowlisted local addresses additionally get the 'allow-same-origin' sandbox token in the iframe: local dev servers (Vite etc.) need a real origin for their module/HMR/fetch pipeline and would otherwise render blank in the opaque-origin sandbox. The page stays cross-origin to the GUI and to every other site. The server-side browser.probe route mirrors the same allowlist so probed local servers are not rejected as 'local addresses are not probed'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
侧边栏浏览器打开阿里云百炼等站点时显示误导性的「拒绝连接请求」(refused to connect)。实际原因不是网络问题:这些站点通过 CSP
frame-ancestors/X-Frame-Options拒绝被嵌入,但browser.probe用 HEAD 请求探测时,服务器(如阿里云)在 HEAD 响应中不返回 CSP/X-Frame-Options 头(只有 GET 响应才携带),导致:修复
HEAD 响应同时缺少
Content-Security-Policy和X-Frame-Options时,回退 GET 重试一次(响应体丢弃、只看响应头)——与现有 405/501 HEAD 回退逻辑同构。修复后客户端能正确拿到
frame-ancestors并显示「该站点拒绝嵌入」面板 + 「在浏览器中打开」按钮。验证
bailian.console.aliyun.com:修复前误判「可嵌入」,修复后正确识别「拒绝嵌入」(GET 响应含frame-ancestors *.aliyun.com)example.com:无回归,仍可正常嵌入改动
src/index.ts的browser.probe路由,新增 11 行。