Redirect to 404 when correct custom [slug] is not found in Next JS #62123
Replies: 1 comment 7 replies
-
You shouldn't use getStaticProps and getStaticPaths in app folder, nor name the file [slug].tsx. Those are methods and formats for the page router. |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I integrated Contentful with GraphQL, and verified all the queries were accurate. I have set up a dynamic rout [slug].tsx called PostPage under /blog/[slug].tsx alongside the BlogClient.tsx and corresponding Page.tsx which renders the page. The [slug].tsx is meant to take me to the page of any selected blog post from my blog page so the individual blog can be read better. However when I click the link from a blog post, although I'm taken to the correct app/blog/slug but receive a 404. I've logged and tested the slug to make sure it matches what's on Contentful and it shows accurately. The following code demonstrates is the set up I have between NextJs, Contentful, GraphQL and the ApolloClient . I have currently tried everything I can possibly think of that could be causing this issue and my conclusion is that everything looks good but the 404 page persists. Even more frustrating, I don't know who to ask to get past this dilemma. Hoping to get some guidance. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions