Repository navigation
fix: Presentation connects again from the Sanity Dashboard - #243
Merged
Merged
Conversation
Every `*.sanity.studio` URL now redirects into the Sanity Dashboard (`www.sanity.io/@org/studio/<appId>`), which frames the Studio, which frames this site. `frame-ancestors` is checked against every ancestor, so the policy that only listed `*.sanity.studio` blocked the Presentation iframe ("Framing ... violates ... frame-ancestors"). A Studio on its own domain opened from the Dashboard sits in the same chain. The policy has been in place since April, but only reaches the HTML since dd59cb3 moved it into next.config, which is why Presentation broke without a preview config change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`useIsPresentationTool()` turns `false` inside a frame when the comlink handshake has not connected after one second, not only outside Presentation. `DisableDraftMode` took that as "outside" and left Draft Mode, which cut Presentation off whenever the Studio was slow to connect (it now sits in the Dashboard's frame), and in the cross-site iframe the disable route cannot clear the partitioned cookie anyway. Leave Draft Mode automatically only on a top-level page that no other window opened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Deploy Preview for bef-next-sanity-starter ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
🟢 Approval recommended
The narrowly scoped changes address both reported failure paths without identified blocking issues, though live logged-in Presentation verification remains outstanding.
No open issues 🎉
What changed in this PR
Restores Sanity Presentation connections when the Dashboard embeds the Studio, addressing iframe permissions and premature Draft Mode cleanup.
Changes:
- Allows Sanity Dashboard subdomains in the
frame-ancestorspolicy. - Prevents automatic Draft Mode exit in frames and windows opened by another page, while retaining standalone-page cleanup.
- Updates setup documentation to reflect the allowed Dashboard origins.
| File | Description |
|---|---|
web/src/components/sanity/DisableDraftMode.tsx |
Guards Draft Mode cleanup in frames and opened windows. |
web/next.config.ts |
Allows Sanity Dashboard origins to frame the site. |
web/.env.example |
Documents Dashboard origins in the Studio URL guidance. |
README.md |
Updates preview setup guidance for Dashboard embedding. |
Review effort: Balanced
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.
Presentation could no longer connect in deployed Studios, without any change to the preview config. Two causes in the starter:
1.
frame-ancestorsblocked the Sanity Dashboard (web/next.config.ts)Every
*.sanity.studioURL now redirects into the Dashboard (www.sanity.io/@org/studio/<appId>), which frames the Studio, which frames the site.frame-ancestorsis checked against every ancestor, so a policy listing only*.sanity.studioblocked the iframe. The policy has existed since April but reaches the HTML only since dd59cb3. Addshttps://*.sanity.io(what Sanity's Dashboard docs recommend) and updates README /.env.example.Live: the starter demo, farbstudio.de, stg-farbstudio, stg-zuhorn and stg-vju send the old policy.
2.
DisableDraftModeleft Draft Mode inside PresentationuseIsPresentationTool()turnsfalseinside a frame after one second without a comlink connection. The component took that as "outside Presentation" and navigated to/api/draft-mode/disable. Now it only does that on a top-level page no other window opened.Verified
Framing … violates … frame-ancestors; loads once the dashboard origin is listed./api/draft-mode/disableright after enable; the new one stays in Draft Mode. Top-level still leaves Draft Mode.pnpm typecheck,pnpm lint,pnpm check:wiring.Not verified: a live Presentation session in a logged-in Studio.
Variant-Port: #244
🤖 Generated with Claude Code