-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
chore: add server-side cookie attributes setting limitation callout #8112
base: main
Are you sure you want to change the base?
Conversation
|
||
**Note:** The Next.js adapter currently doesn't support customization of cookie attributes from the server side, and cookies are always set with [default attribute values](https://github.com/aws-amplify/amplify-js/blob/2447917fb47ff616aca6f5d64f9c635cf738c7e3/packages/aws-amplify/src/adapter-core/storageFactories/createKeyValueStorageFromCookieStorageAdapter.ts#L10-L15). | ||
|
||
If you are changing the cookie store on the client side, you may need to manually set the cookie attributes to match the server-side configuration. If you need to customize the cookie attributes, you can use the lower level [`runWithAmplifyServerContext` function](/gen1/[platform]/build-a-backend/server-side-rendering/) instead. |
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.
Should we remove the "gen1" in the linked SSR docs here?
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.
Good Q, we currently don't have a equivalent Gen2 page for the lower level adapter function. Open for suggestions.
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.
does this page have the info we're looking for? https://docs.amplify.aws/react/build-a-backend/server-side-rendering/#configure-amplify-apis-for-server-side-usage
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.
@josefaidt the Gen2 doc page contains only the information about the prebuilt Next.js adapter.
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.
If its in gen1 docs and gen2 but important to customers. Shouldnt we move this over?
|
||
**Note:** The Next.js adapter currently doesn't support customization of cookie attributes from the server side, and cookies are always set with [default attribute values](https://github.com/aws-amplify/amplify-js/blob/2447917fb47ff616aca6f5d64f9c635cf738c7e3/packages/aws-amplify/src/adapter-core/storageFactories/createKeyValueStorageFromCookieStorageAdapter.ts#L10-L15). | ||
|
||
If you are changing the cookie store on the client side, you may need to manually set the cookie attributes to match the server-side configuration. If you need to customize the cookie attributes, you can use the lower level [`runWithAmplifyServerContext` function](/gen1/[platform]/build-a-backend/server-side-rendering/) instead. |
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.
@HuiSF I am the one who opened aws-amplify/amplify-js#14026.
Thank you for updating the documentation.
I think the page you are trying to refer to in the documentation is the following:
https://docs.amplify.aws/gen1/nextjs/build-a-backend/server-side-rendering/
That page includes the following description:
You can create the storage object by using the utility function
createKeyValueStorageFromCookieStorageAdapter
exported fromaws-amplify/adapter-core
.
The implementation example also uses createKeyValueStorageFromCookieStorageAdapter
.
However, createKeyValueStorageFromCookieStorageAdapter
itself is implemented to use the default cookie attributes.
Therefore, even if I follow the instructions on that page, I may not be able to configure the cookie attributes.
I think it would be better to mention that keyValueStorage
must be implemented without using createKeyValueStorageFromCookieStorageAdapter
.
Description of changes:
Added callout of the limitation for setting cookie attributes from the server side with Amplify Next.js adapter.
Related GitHub issue #, if available:
aws-amplify/amplify-js#14026
Instructions
If this PR should not be merged upon approval for any reason, please submit as a DRAFT
Which product(s) are affected by this PR (if applicable)?
Which platform(s) are affected by this PR (if applicable)?
Please add the product(s)/platform(s) affected to the PR title
Checks
Does this PR conform to the styleguide?
Does this PR include filetypes other than markdown or images? Please add or update unit tests accordingly.
Are any files being deleted with this PR? If so, have the needed redirects been created?
Are all links in MDX files using the MDX link syntax rather than HTML link syntax?
ref: MDX:
[link](https://docs.amplify.aws/)
HTML:
<a href="https://docs.amplify.aws/">link</a>
When this PR is ready to merge, please check the box below
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.