搬运自 stackoverrflow
直接贴代码
export const getServerSideProps = wrapper.getSererSideProps(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']), } } })
![]() | 1 summerwar 2021-07-01 13:57:07 +08:00 我觉得发帖子除了直接贴代码之外,也可以进行简单的说明 |
![]() | 2 mightofcode OP @summerwar 好的 |