Troubleshooting Visual Editing with Sanity and cookie issues

4 replies
Last updated: Oct 24, 2024
I’m trying to implement Visual Editing following this guide: https://www.sanity.io/guides/nextjs-app-router-live-preview .My implementation differs in that my studio is hosted on sanity.studio url instead of being embedded in Next.
Does Visual Editing (Presentation) require the studio to be on the same domain?

One of the issues i see is that the
__prerender_bypass
cookie does not work as expected.• I open my sanity.studio and go to “presentation”
• I can see in the network request that the cookie is actually being set once the
/api/draft
request is triggered• Editing and preview works as expected.
• However, when i open a new tab and visit the website, the
__prerender_bypass
cookie is not set.I suspect this might be because in sanity.studio, the preview is loaded inside and iframe and that the browser restrict the cookie on other tabs/windows.

Any thoughts or suggestions?
Oct 22, 2024, 7:20 AM
👋 Visual editing doesn't require you to be on the same domain. Which browser are you using?
Oct 22, 2024, 3:17 PM
Brave.
Oct 22, 2024, 4:11 PM
I can see that the cookie response headers looks correct with SameSite=None and Secure.If i enable third party cookies in Brave, it works.
Oct 22, 2024, 4:12 PM
Right, but does it really require third party cookies to work?I mean, no browser will support this pretty soon… If this is by design, then i would suggest throwing up a big gotcha in the docs
Oct 24, 2024, 5:20 PM

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?