Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change type of GetServerSidePropsContext.req.cookies the be the same as NextApiRequest.cookies #21336

Merged
merged 10 commits into from Jan 26, 2021
10 changes: 8 additions & 2 deletions packages/next/next-server/server/render.tsx
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion packages/next/types/index.d.ts
Expand Up @@ -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'

Expand Down Expand Up @@ -130,7 +135,7 @@ export type GetServerSidePropsContext<
Q extends ParsedUrlQuery = ParsedUrlQuery
> = {
req: IncomingMessage & {
cookies?: { [key: string]: any }
cookies: NextApiRequestCookies
}
res: ServerResponse
params?: Q
Expand Down