You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus/docs/cms/features/preview.md
+136-5Lines changed: 136 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -291,7 +291,142 @@ export async function GET(request: Request) {
291
291
292
292
On the Strapi side, [the `allowedOrigins` configuration parameter](#allowed-origins) allows the admin panel to load the front-end window in an iframe. But allowing the embedding works both ways, so on the front-end side, you also need to allow the window to be embedded in Strapi's admin panel.
293
293
294
-
This requires the front-end application to have its own header directive, the CSP `frame-ancestors` directive. Setting this directive up depends on how your website is built. For instance, setting this up in Next.js requires a middleware configuration (see <ExternalLinkto="https://nextjs.org/docs/app/building-your-application/configuring/content-security-policy"text="Next.js docs"/>).
294
+
This requires the front-end application to have its own header directive, the CSP `frame-ancestors` directive. Setting this directive up depends on how your website is built. For instance, setting this up in Next.js requires a middleware configuration (see [Next.js docs](https://nextjs.org/docs/app/building-your-application/configuring/content-security-policy)).
295
+
296
+
#### 6. [Front end] Detect changes in Strapi and refresh the front-end {#6-refresh-frontend}
297
+
298
+
Strapi emits a `strapiUpdate` message to inform the front end that data has changed.
299
+
300
+
To track this, within your front-end application, add an event listener to listen to events posted through [the `postMessage()` API](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) on the `window` object. The listener needs to filter through messages and react only to Strapi-initiated messages, then refresh the iframe content.
301
+
302
+
With Next.js, the recommended way to refresh the iframe content is with <ExternalLinkto="https://nextjs.org/docs/app/building-your-application/caching#routerrefresh"text="the `router.refresh()` method" />.
In Next.js, [cache persistence](https://nextjs.org/docs/app/building-your-application/caching) may require additional steps. You might need to invalidate the cache by making an API call from the client side to the server, where the revalidation logic will be handled. Please refer to Next.js documentation for details, for instance with the [revalidatePath() method](https://nextjs.org/docs/app/building-your-application/caching#revalidatepath).
- with <GrowthBadge/> and <EnterpriseBadge /> plans, expandthesidepanelbyclickingonthe <Iconname="arrow-line-left"classes="ph-bold"/>buttontomakethePreviewfullscreen,
0 commit comments