Hi there,
I'm having trouble getting the preview working with Prismic and a static Nuxt site deployed on Netlify.
Have read through the preview troubleshooting, and this forum (where I see a lot of preview not working posts).
My nuxt.config is setup like this:
export default {
ssr: "true",
loading: false,
target: "static",
generate: {
fallback: "true",
},
plugins: ["~/plugins/vue-imgix.js"],
components: true,
buildModules: ["@nuxtjs/prismic", "@nuxtjs/dotenv"],
modules: ["@nuxtjs/style-resources"],
prismic: {
endpoint: "https://reponame.prismic.io/api/v2",
linkResolver: "@/plugins/link-resolver",
preview: "/preview",
},
};
I'm using a link-resolver as follows:
export default function (doc) {
if (doc.isBroken) {
return "/error";
}
if (doc.type === "home_page") {
return "/";
}
if (doc.type === "work_page") {
return "/work/";
}
if (doc.type === "contact_page") {
return "/contact/";
}
if (doc.type === "insights_page") {
return "/insights/";
}
if (doc.type === "about_page") {
return "/about/";
}
if (doc.type === "studio_page") {
return "/studio/";
}
if (doc.type === "menu") {
return "/";
}
if (doc.type === "social") {
return "/";
}
if (doc.type === "category") {
return "/";
}
if (doc.type === "page") {
return "/page/" + doc.uid;
}
if (doc.type === "project") {
return "/project/" + doc.uid;
}
if (doc.type === "article") {
return "/insight/" + doc.uid;
}
return "/";
}
Here is how my setup is on the prismic end:
The io.prismic.preview cookie is added to the application with a value of:
{%22_tracker%22:%22tf9wCT0N%22%2C%22reponame.prismic.io%22:{%22preview%22:%22https://reponame.prismic.io/previews/YWcwhhQAACEAtWHi:YWcxkxQAACIAtWal?websitePreviewId=YWX2OxQAACEAsFfh%22}}
At the moment preview just redirects to the homepage everytime. ¯_(ツ)_/¯
Any tips as to what I am doing wrong would be great, as this is a feature I'd love for my clients to be able to use!