fix(browser): probe embed signals via GET fallback when HEAD omits them
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.
This commit is contained in:
@@ -393,6 +393,17 @@ function buildApi(
|
||||
if (response.status === 405 || response.status === 501) {
|
||||
response = await fetch(parsed, { method: 'GET', redirect: 'follow', signal: controller.signal })
|
||||
}
|
||||
// Some servers (e.g. aliyun consoles) answer HEAD without the
|
||||
// X-Frame-Options / CSP headers that only their GET response
|
||||
// carries. Without those signals the embeddability check below
|
||||
// would wrongly report the site as embeddable and the plain iframe
|
||||
// would surface the browser's misleading "refused to connect".
|
||||
// Retry once as GET when both signals are absent (body discarded).
|
||||
const hasEmbedSignals = response.headers.get('content-security-policy') !== null
|
||||
|| response.headers.get('x-frame-options') !== null
|
||||
if (!hasEmbedSignals && response.status !== 405 && response.status !== 501) {
|
||||
response = await fetch(parsed, { method: 'GET', redirect: 'follow', signal: controller.signal })
|
||||
}
|
||||
const csp = response.headers.get('content-security-policy')
|
||||
const frameAncestors = extractFrameAncestors(csp)
|
||||
const xFrameOptions = response.headers.get('x-frame-options')
|
||||
|
||||
Reference in New Issue
Block a user