2022-05-08 21:32:40 +03:00

32 lines
695 B
TypeScript

import initializeApollo from 'apollo/client';
import type { GetServerSideProps } from 'next';
import { fetchUser } from 'services/user';
import type { BasePageProps } from 'types/page';
interface PageProps extends BasePageProps {}
function Home() {
return <div>Home</div>;
}
export const getServerSideProps: GetServerSideProps<PageProps> = async (ctx) => {
const user = await fetchUser({
headers: ctx?.req?.headers?.cookie
? {
cookie: ctx.req.headers.cookie,
}
: undefined,
});
const apolloClient = initializeApollo();
return {
props: {
user,
initialApolloState: apolloClient.cache.extract(),
},
};
};
export default Home;