Closed wishiz closed 3 years ago
Hey @wishiz, thanks for opening an issue!
It looks like the cookie affected in your screenshot is coming from Mixpanel, an analytics service we're using at Prismic.
Thanks!
Hello @lihbr , sorry for misunderstanding. The preview page is loaded, but the published changes are not applied until we rebuild the project.
We tried using forked nuxt-community/prismic-module
and updating @prismicio/client
from 4.0.0 to 5.1.0 within it, then changes started to be applied when project built in dev mode and previewing locally, but still no luck when built with nuxt generate
No worries!
The preview page is loaded, but the published changes are not applied until we rebuild the project.
Do you mean saved changes? If published, indeed publishing changes require a website rebuild to be taken into account with a statically generated website.
We tried using forked nuxt-community/prismic-module and updating @prismicio/client from 4.0.0 to 5.1.0 within it
Updating should have no effect for you here, version 4.0.0 is the same as 5.0.0, version 5.1.0 only bringing a new feature to deal with the new tag API.
Basically, the Prismic preview feature allows you to preview unpublished, saved changes by using your website (Nuxt) SPA capabilities. The preview feature cannot preview published changes and those won't appear unless you rebuild your static website. This can be done automatically using the webhook feature ☺️
Thank you for clearing this out :)
Still, unpublished changes are not applied as well, with the same cookie error.
What we want to achieve is to have the ability to preview changes of documents on a statically generated website.
Ok great!
Looking at your Nuxt configuration everything looks alright:
~/pages/preview.vue
? Having a said page would conflict with the module preview resolving (if you want to customize the preview resolving page you still can)/preview
as configured in your Nuxt config file.body
tag.Awesome, thanks!
Everything looks alright for me here. I'm starting to run a bit out of ideas but we'll find out why previews aren't working for you, no worries ☺️
Thank you for looking into the matter :)
~/pages/index.vue
~/plugins/i18n.ts
declare module 'vue/types/vue' { interface Vue { $loadTranslation(docType: string, options: any): any } }
const getI18n = ({ $prismic, app }, inject) => { const getCurrentLocale = (customLocale?: string) => { const locale = customLocale || app.i18n.locale const currentLocale = app.i18n.locales.filter((lang) => lang.code === locale)[0] const lang = currentLocale.iso.toLowerCase()
return lang
}
const loadTranslation = async (uid: string, options = {}, id: string = 'document.type') => { const predicates = [$prismic.predicates.at(id, uid)] const lang = getCurrentLocale() const fallbackLang = getCurrentLocale(app.i18n.fallbackLocale)
const defaultOptions = { lang }
// fething data with current lang
const currentLangData = await $prismic.api.query(predicates, { ...defaultOptions, ...options })
if (currentLangData.results.length) {
return currentLangData
}
// fething data with fallback lang
const fallbackLangData = await $prismic.api.query(predicates, { lang: fallbackLang })
return fallbackLangData
}
inject('getCurrentLocale', getCurrentLocale) inject('loadTranslation', loadTranslation) }
export default getI18n
Ok I think I got it!
Can you try removing the if statement on your asyncData
method? (if (process.server || isDev) {
)
I think it is preventing your website from refreshing the data once statically generated because it needs to run the asyncData
method on the client side in order to get preview data.
Let me know if that's unclear but that'd be explaining why it's working in the development server and not on production also :)
Thank you for the answer and sorry for the delay!
Makes total sense and it indeed fixed the issue. I appreciate your support :)
You're welcome! Feel free to reach out to us again in case of any trouble, either on GitHub or our community forum ☺️
Hi guys, our team has recently experienced an issue with cookies samesite attribute when previewing Prismic documents. We hope you could help us. Please let us know if we should re-address the question.
Reproduction
Log into Prismic repository dashboard > access document > click Preview
What is expected
Open the app preview
What is actually happening
The following error appears:
Versions
Additional Details
We preview the app on localhost and via AWS staging > issue is reproduced on both.
If you need more information, just let us know. We assume it could be hotfixed by adjusting browsers cookie settings, but we're not up to use it as a long-term decision.
Related: https://github.com/nuxt-community/prismic-module/issues/144