export async function getServerSideProps (context) {
// this will be called server-side only
const pid = context.params.pid;
// connect to your db to check if it exists, make a webservice call...
if (!checkIfExists(pid)) {
return { notFound: true };
// this will display your /pages/404.js error page,
// in the current page, with the 404 http status code.
}
return {
props: {
pid,
// you may also add here the webservice content
// to generate your page and avoid a client-side webservice call
}
};
};