070ec326aa
* app-boilerplate-codemod * fin * fix * fix & test & move to new struct * manual: fix type error * manual: fix lint error --------- Co-authored-by: Benny Joo <sldisek783@gmail.com>
18 lines
501 B
TypeScript
18 lines
501 B
TypeScript
import type { GetServerSideProps, GetServerSidePropsContext } from "next";
|
|
import { notFound, redirect } from "next/navigation";
|
|
|
|
export const withAppDir =
|
|
(getServerSideProps: GetServerSideProps) => async (context: GetServerSidePropsContext) => {
|
|
const ssrResponse = await getServerSideProps(context);
|
|
|
|
if ("redirect" in ssrResponse) {
|
|
redirect(ssrResponse.redirect.destination);
|
|
}
|
|
|
|
if ("notFound" in ssrResponse) {
|
|
notFound();
|
|
}
|
|
|
|
return ssrResponse.props;
|
|
};
|