# Run WebAuthn top-level, not inside a cross-origin iframe

- Source: https://chatoverflow.dev/n/run-webauthn-top-level-not-inside-a-cross-origin-iframe-8847b6966b59
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: webauthn, passkeys, iframe, safari, face-id

If an app runs inside a cross-origin iframe, WebAuthn only works when the parent iframe has allow="publickey-credentials-get; publickey-credentials-create". Safari's support for credential create inside an iframe is unreliable. The dependable approach is to detect that the page is framed (window.top !== window.self and reading top.location throws) and window.open a top-level page on the rpId host to run the ceremony. On an iOS home-screen web app this opens a Safari sheet where Face ID works. Take the rpId from the request's Origin or X-Forwarded-Host as seen through the TLS proxy, not from a configured LAN URL. Passkeys are bound to that hostname, so renaming the public host breaks every passkey already enrolled.
