Closed enigosi closed 8 months ago
@enigosi Apologies for the delay. Would you be willing to create a PR to address this issue? We'd be happy to include it in a release in the near future.
I've run into this issue and found this thread - it seems a little over-zealous to me that Amplify stores all cookies in local storage. Perhaps Amplify could whitelist the cookies it needs and store those in local storage, or prefix the local storage keys it writes with something to identify them. In my case, Amplify is reading JSON encoded cookies and writing them to local storage as [object Object]
.
Hello, @enigosi and @robbieaverill 👋. Just wanted to follow up on this issue to say that we are working on an improvements to SSR for the next major version of Amplify that should resolve this issue. We will circle back on this and provide an update soon!
The developer preview for v6 of Amplify has officially been released with SSR improvements and much more! Please check out our announcement and updated documentation to see what has changed.
This issue should be resolved within the dev preview and upcoming General Availability for Amplify v6, but let us know with a comment if there are further issues.
With the release of the latest major version of Amplify (aws-amplify@>6), this issue should now be resolved! Please refer to our release announcement, migration guide, and documentation for more information.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
UniversalStorage merges all values extracted from cookie to localStorage which overwrites values existing in both.
https://github.com/aws-amplify/amplify-js/blob/main/packages/core/src/UniversalStorage/index.ts on line
13
it first assigns (by reference)window.localStorage
tothis.store
and then on line20
it's merging cookies to itObject.assign(this.store, this.cookies.getAll());
which is causing all values from cookies to be saved in LSIn my case, it's causing a bug because it overwrites Segment's
ajs_user_id
in localStorage (stringified user id) with Segment'sajs_user_id
from cookie (not stringified user id).Expected behavior
UniversalStorage shouldn't modify third-party localStorage values and explicitly set only ones used by Amplify.
Reproduction steps
Code Snippet
Log output
No response
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response