Why draft mode working only on localhost, but not on vercel?
Unanswered
Somali posted this in #help-forum
SomaliOP
Working on something like a "draft" mode.
I have a JSON file for all pages with the 'published' flag.
On the home page, I assemble the page like this:
On other dynamic pages, I do it like this:
So, if the 'published' flag is false, I don't include it in the initial application build. However, if it's false and 'draftMode' is true, then I show these pages.
But for some reason, the version with the 'published' flag (previously, I was just filtering by language and draft mode) doesn't work on Vercel, although it works locally and in dev mode, and in the built version (npm run build -> npm run start).
What am I missing?
I have a JSON file for all pages with the 'published' flag.
On the home page, I assemble the page like this:
export async function getStaticProps({ locale, locales, draftMode }) {
const data = await getPageData(locale, 'home');
const globalProps = await getGlobalData(locale);
console.log(data.published);
if (!data.published && !draftMode) {
return {
notFound: true,
};
}
const props = {
data,
globalProps,
locales,
};
if (draftMode !== undefined) {
props.draftMode = draftMode;
}
return {
props,
revalidate: 1,
};
}On other dynamic pages, I do it like this:
export async function getStaticProps({ params, locale, locales, draftMode }) {
const data = await getPageData(locale, params.slug);
const globalProps = await getGlobalData(locale);
console.log('kek:', data.published, draftMode);
if (!data.published && !draftMode) {
return {
notFound: true,
};
}
const props = {
data,
globalProps,
locales,
};
if (draftMode !== undefined) {
props.draftMode = draftMode;
}
return {
props,
revalidate: 1,
};
}
export async function getStaticPaths({ locales }) {
...
}So, if the 'published' flag is false, I don't include it in the initial application build. However, if it's false and 'draftMode' is true, then I show these pages.
But for some reason, the version with the 'published' flag (previously, I was just filtering by language and draft mode) doesn't work on Vercel, although it works locally and in dev mode, and in the built version (npm run build -> npm run start).
What am I missing?