-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only when preview mode is on, the newly added slug page can be seen. #212
Comments
Are you sure you set up the webhook that revalidates and triggers a page rebuild correctly? Webhooks also have an attempt log, that can show you if the revalidate function has been called correctly, and if not, what may be wrong. |
@AruhaMaeda Also, this may be a bad fallback setting. Take a look at this: // pages/posts//[slug].tsx
export const getStaticPaths = async () => {
const slugs = await getAllPostsSlugs()
return {
paths: slugs?.map(({ slug }) => `/posts/${slug}`) || [],
fallback: false,
}
} Do you see that fallback false? Well, that is probably the problem, because: Sanity: Hey, Next.js, I changed some content, I sent you a request to revalidate some pages. Next.js API: Let me take a look at which pages you want to revalidate. Oh, you want to revalidate articles too? Ok, I revalidated almost all articles except the new one, you have created. But that article wasn't generated at the build time so I can't revalidate it! It's Yeah, so it's probably because of this. Setting it to return {
paths: slugs?.map(({ slug }) => `/posts/${slug}`) || [],
fallback: "blocking",
} https://nextjs.org/docs/api-reference/data-fetching/get-static-paths#fallback-false |
Thank you for your response! As you said, I didn't set up revalidates so I did it but still did not reflect the changes correctly. Finally, as you suggested, I changed fallback false to blocking, and it works! Thank you very much. return {
paths: slugs?.map(({ slug }) => `/posts/${slug}`) || [],
fallback: "blocking",
} |
@AruhaMaeda Glad you got it working! I opened a PR: #213 |
thanks so much for this, had the same problem this fixed it |
I want to ask whether this is a bug or something wrong setting.
Only when preview mode is on, the newly added slug page can be seen.
If I exit from preview mode, get 404.
I deployed from Vercel template, and I added CORS setting to my sanity project. (I don't change any code. )
video is below
Next.js.Blog.with.Sanity.io.Desk.-.13.February.2023.1.mp4
The text was updated successfully, but these errors were encountered: