Hey,
I have an issue with my NEXT.JS & Prismic project, where pages only get build when running yarn dev
but Prismic returns null
when running yarn build
.
Here is the link to the repo: https://github.com/hejsfj/mateo-website
This is how I am querying the page:
export async function getPage(slug, previewData) {
const data = await fetchAPI(
query PageBySlug($slug: String!, $lang: String!) {
page(uid: $slug, lang: $lang) {
title
body {
__typename
...on PageBodyPlain_hero{
type
label
primary{
section_title
}
}
...on PageBodyText{
type
label
primary{
section_description
}
}
}
_meta {
uid
}
}
}
`,
{
previewData,
variables: {
slug,
lang: API_LOCALE,
},
}
);
return data;
}
Thats how I am consuming the data on the page:
export async function getStaticProps({ params, preview = false, previewData }) {
const data = await getPage(params.page, previewData);
return {
props: {
preview,
page: data?.page ?? null,
},
};
}
export async function getStaticPaths() {
const allPages = await getAllPagesWithSlug();
return {
paths: allPages?.map(({ node }) => `/${node._meta.uid}`) || [],
fallback: true,
};
}
data?.page is undefined when deploying for some reason. When running with yarn dev this works just as desired.
Does someone know why this is the case?