-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
Update getServerSideProps docs with req.cookie note #29457
Update getServerSideProps docs with req.cookie note #29457
Conversation
a73295b
to
6214bfa
Compare
docs/basic-features/data-fetching.md
Outdated
### Built-in `context.req` parsing | ||
|
||
To improve the developer experience, the `context.req` request object received by `getServerSideProps` is pre-parsed to include some additional helpful properties. Those properties are: | ||
|
||
- `context.req.cookies` - An object containing the cookies sent by the request. Defaults to `{}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I was thinking there were more helpers than just cookies
but then I checked the type and its just cookies
like you mentioned
next.js/packages/next/types/index.d.ts
Lines 148 to 151 in c27e3a4
req: IncomingMessage & { | |
cookies: NextApiRequestCookies | |
} | |
res: ServerResponse |
And it looks like res
doesn't have any helpers so maybe its best to go back to your original commit where it was mentioned inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we discovered a strange behavior where getServerSideProps()
differs to much from API Routes and we should try to use the same helpers for both 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I don't think it hurts to have this extra section, even if it just talks about 1 helper. Nice for google foo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @molebox, I like that we'd be able to deeplink to this section. Additionally, this makes it easier to expand the list in the future if we do want to get to parity with the API route helpers
docs/basic-features/data-fetching.md
Outdated
### Built-in `context.req` parsing | ||
|
||
To improve the developer experience, the `context.req` request object received by `getServerSideProps` is pre-parsed to include some additional helpful properties. Those properties are: | ||
|
||
- `context.req.cookies` - An object containing the cookies sent by the request. Defaults to `{}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I don't think it hurts to have this extra section, even if it just talks about 1 helper. Nice for google foo
Co-authored-by: Rich Haines <hello@richardhaines.dev>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@molebox do you have the super powers necessary to approve running the workflows? |
@Vitorba |
Tweak the wording of the new getServerSideProps middleware section so it matches closer to the one in https://nextjs.org/docs/api-routes/api-middlewares. Co-authored-by: JJ Kasper <jj@jjsweb.site>
@ijjk thanks, good tweaks! Added 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Documentation / Examples
Add a note to the
getServerSideProps
docs thatcontext.req
contains acontext.req.cookies
attribute.I based the copy off of the one from https://nextjs.org/docs/api-routes/api-middlewares.
Checklist: