webdev3
(Web Dev)
November 1, 2023, 4:52am
1
Prismic preview is not working properly, its always opening home page instead of actual preview route.
I'm using default preview file only, do I need to change anything ?
import { redirectToPreviewURL } from "@prismicio/next";
import { createClient } from "@/prismicio";
/**
* @param {import("next/server").NextRequest} request
*/
export async function GET(request) {
const client = createClient();
await redirectToPreviewURL({ client, request });
}
Hey @webdev3 ,
Is your route resolver up to date with route objects for all of the routes on your website?
Sam
webdev3
(Web Dev)
November 2, 2023, 7:34am
3
Sharing my prismicio.js, Is this enough or do I need to add this somewhere else
const routes = [
{
type: "solution_pages",
path: "/solutions/:uid"
},
{
type: "industry_pages",
path: "/industries/:uid",
},
{
type: "product_pages",
path: "/products/:uid",
},
{
type: "case_studies",
path: "/resources/case-studies/:uid",
},
{
type: "resources_hub_pages",
path: "/resources/:uid",
},
{
type: "landing_pages",
path: "/lp/:uid",
},
{
type: "page",
path: "/:uid",
},
{
type: "page",
uid: "home",
path: "/",
},
{
type: "settings",
path: "/",
}
];
export const createClient = (config) => {
const client = prismic.createClient(repositoryName, {
routes,
accessToken: process.env.PRISMIC_ACCESS_TOKEN,
fetchOptions:
process.env.NODE_ENV === "production"
? { next: { tags: ["prismic"] }, cache: "force-cache" }
: { next: { revalidate: 5 } },
...config,
});
prismicNext.enableAutoPreviews({ client });
return client;
};
Hi @webdev3 ,
Based on the information available, I can't say for sure what the problem is. Try looking at our troubleshooting guide and let me know if that helps:
Sam