Next v10 allows to return 404 page (not with props, but just plain as it is below)
if (!checkItem) {
return {
notFound: true
}
}
Full code that works for me: ✅✅✅
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']),
}
}
})
Documentation: https://nextjs.org/blog/next-10#notfound-support