搬运自 stackoverrflow
直接贴代码
export const getServerSideProps = wrapper.getServerSideProps(async ({ req, res, locale, query, store }) => {
  const { productId, categoryId } = query
   
  const checkItem = await getProductBySlugSSR(productId, categoryId, store)
  if (!checkItem) {
    return { // <-----------------does the trick here!!
      notFound: true
    }
  }
    
  return {
    props: {
      ...await serverSideTranslations(locale, ['common']),
    }
  }
})
|  |      1summerwar      2021-07-01 13:57:07 +08:00 我觉得发帖子除了直接贴代码之外,也可以进行简单的说明 | 
|  |      2mightofcode OP @summerwar 好的 |