I've set up previews on a Nuxt 3 project with slicemachine. This works fine for index, but if I preview any other page it always shows the index. The site is hosted on Netlify, which is where the preview points to.
These are the settings i'm using in nuxt.config.ts:
I've removed the trailing slash, but it still shows the index.
Edit:
I might as well include the code snippet that fetches the page data.
I suspect this could be the culprit, since it fetches all page documents, that might cause this issue, but that's just a guess.
import { components } from '~/slices';
import { Content } from "@prismicio/client";
const prismic = usePrismic();
const route = useRoute();
const response = await useAsyncData(route.params.uid as string, () =>
prismic.client.getAllByType('page', {
fetchLinks: [
'questionanswer.items'
]
})
);
const pages = response.data as Ref<Content.PageDocument<string>[]>
let page: Content.PageDocument<string> | null = null;
for(let i = 0; i < pages.value.length; i++) {
if(pages.value[i].uid === route.params.uid) {
page = pages.value[i];
}
}
if(!page) {
console.error('Pagina niet gevonden')
throw createError({
message: 'Pagina niet gevonden',
statusCode: 404,
fatal: true
})
}