Getting 500 error page instead of 404 - a getStaticProps issue?

Hi

The website I'm currently working on is throwing 500 error pages for pages that don't exist, instead of 404 error pages.

I seem to only be getting the issue when visiting a route that would actually map to a page file if it exists - i.e. /about would map to my /pages/[uid].tsx route. In this case, if the /about page document didn't exist in my Prismic backend it would give me a 500 error.

If the route doesn't map to a page file i.e. /afd/fsdaf (/pages/[parent]/[uid].tsx file doesn't exist, therefore it doesn't have a page file to map to), then it does correctly show the 404 error.

I'm assuming on this basis that this issue I'm facing is being caused by something inside the page files.

I seem to be getting the same issue on another recent project, but not on an older project which uses the old useGetStaticPaths hook. So my instinct is that it's perhaps something I'm doing wrong with getStaticPaths function for these newer projects.

Here is how my getStaticPaths code looks:

export const getStaticPaths: GetStaticPaths = async () => {
  const documents: Doc[] = await queryRepeatableDocuments(
    (doc) => doc.type === 'page',
  );
  return {
    paths: documents.map((doc) => `/${doc.uid}`),
    fallback: false,
  };
};

Is there something I'm doing wrong here?

Hello @david.al.fox

Thanks for reaching out to us.

We have already discussed the same issue in the following thread:

Let me know if you have any further questions.

Thanks,
Priyanka

This works, thanks!

I am glad that this works for you. Feel free to reach out to us if you have any questions.