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

CookieYes causes rehydration #76

Closed
meza opened this issue Mar 11, 2023 · 3 comments · Fixed by #99
Closed

CookieYes causes rehydration #76

meza opened this issue Mar 11, 2023 · 3 comments · Fixed by #99
Labels
bug Something isn't working

Comments

@meza
Copy link
Owner

meza commented Mar 11, 2023

What happened?

When cookieyes loads in, it adds a few extra elements which trigger a rehydration.
Unfortunately that also resets all the work the user color mode preference sensors have done, which then cause weird flashing especially for people with a dark mode preference.

What did you expect to happen?

I would expect to not have any hydration issues.

The problem is that cookieyes needs to be loaded before everything else (hotjar and mixpanel) so that it could block the cookies they might use. This is important because regulation states that we can't use those cookies until consent is given.

What version of Remix are you using?

1.14.1

@meza meza added the bug Something isn't working label Mar 11, 2023
@meza
Copy link
Owner Author

meza commented Mar 12, 2023

After doing some research, it seems like the way forward is to lose the cookie services and implement a simple solution using https://www.npmjs.com/package/react-cookie-consent.

Preventing the cookies to load before the user consents is relatively straightforward.

This example prevents anything but the __session cookie - which is something we want.

image

@meza
Copy link
Owner Author

meza commented Mar 13, 2023

So at the heart of the issue is a trade-off between an easy to maintain cookie consent form and good security.

Seems like the nonce-based CSP is something most consent providers can't deal with, so we need to get creative. I'm tempted to take the brute-force approach and only conditionally render the analytics scripts based on the user's consent. This would potentially mean that the first visit gets missed by hotjar and google but at least we'll be compliant AND XSS-safe

@meza meza linked a pull request Mar 31, 2023 that will close this issue
@meza meza closed this as completed in #99 Apr 2, 2023
@meza
Copy link
Owner Author

meza commented Apr 2, 2023

Well this has blown up big time but we've figured it out... Here's the conclusion:

https://github.com/meza/trance-stack/blob/main/docs/adr/0013-custom-cookie-consent.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant