Static preview#2295
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
This is really good! 2 things about the next.js guide part:
|
|
I just checked the user guide part, it looks good to me. This is great work, thanks @pwizla! |
Co-authored-by: Marc Roig <marc12info@gmail.com>
|
@remidej I did my best to improve the implementation guide based on your feedback 😊 What do you think? |
| 1. Create or adapt your data fetching utility to check if draft mode is enabled | ||
| 2. Update your API calls to include the draft status parameter when appropriate | ||
|
|
||
| The following, taken from the [Launchpad](https://github.com/strapi/LaunchPad/tree/feat/preview) Strapi demo application, is an example of how to implement draft-aware data fetching in your Next.js front-end application: |
There was a problem hiding this comment.
Note that these links are pointing to the feat/preview branch of the launchpad repo, which will 404 when we merge our PR on the main branch. Hopefully next week after the CMS release
There was a problem hiding this comment.
Thanks for the reminder! Yes, I'm used to it, and still haven't found a satisfying solution to automate this in some way. Any idea? 🤔 Or maybe is there another format of URLs that would persist across merges? 🤔
I'll update it once the strapi/strapi branch is merged.
There was a problem hiding this comment.
I guess you could link to the repo's tree for a specific commit, this will never 404: https://github.com/strapi/LaunchPad/tree/faa960bf8ca824f5b92dc984c4627abeb87b85eb
But the downside is you wouldn't get any potential improvement that comes in the future. Maybe with a self reminder to update the commit once in a while it could work?
There was a problem hiding this comment.
I'm realizing now there's one last step needed to get the whole thing to work. Apologies for not seeing this earlier.
The permissions to load an iframe go both ways:
- the parent window needs to allow loading the child window (that we do, it's the allowedOrigins thing)
- the child window (the preview site) needs to allow being embedded in the parent (the admin)
That second step requires the preview frontend to have its own header directive: the CSP frame-ancestors directive. The way to set it up will depend on how they build their site. For nextjs it requires a middleware config: https://nextjs.org/docs/app/building-your-application/configuring/content-security-policy
There was a problem hiding this comment.
Many thanks for all these details, @remidej ! I've just updated the docs. Are we good to merge the PR this afternoon?
This PR adds docs for Static Preview (it targets the beta version, so no mention of feature flags):