diff --git a/packages/next/next-server/server/render.tsx b/packages/next/next-server/server/render.tsx index 5cda0722c6553ce..2044373d6a44774 100644 --- a/packages/next/next-server/server/render.tsx +++ b/packages/next/next-server/server/render.tsx @@ -44,7 +44,11 @@ import { NextComponentType, RenderPage, } from '../lib/utils' -import { tryGetPreviewData, __ApiPreviewProps } from './api-utils' +import { + tryGetPreviewData, + NextApiRequestCookies, + __ApiPreviewProps, +} from './api-utils' import { denormalizePagePath } from './denormalize-page-path' import { FontManifest, getFontDefinitionFromManifest } from './font-utils' import { LoadComponentsReturnType, ManifestItem } from './load-components' @@ -796,7 +800,9 @@ export async function renderToHTML( try { data = await getServerSideProps({ - req, + req: req as IncomingMessage & { + cookies: NextApiRequestCookies + }, res, query, resolvedUrl: renderOpts.resolvedUrl as string, diff --git a/packages/next/types/index.d.ts b/packages/next/types/index.d.ts index 3a18b705f9a330e..8c70d3ecfc0a4b1 100644 --- a/packages/next/types/index.d.ts +++ b/packages/next/types/index.d.ts @@ -15,6 +15,11 @@ import { // @ts-ignore This path is generated at build time and conflicts otherwise } from '../dist/next-server/lib/utils' +import { + NextApiRequestCookies, + // @ts-ignore This path is generated at build time and conflicts otherwise +} from '../dist/next-server/server/api-utils' + // @ts-ignore This path is generated at build time and conflicts otherwise import next from '../dist/server/next' @@ -130,7 +135,7 @@ export type GetServerSidePropsContext< Q extends ParsedUrlQuery = ParsedUrlQuery > = { req: IncomingMessage & { - cookies?: { [key: string]: any } + cookies: NextApiRequestCookies } res: ServerResponse params?: Q