Skip to content

Commit

Permalink
fix(cookie-consent): use conditional access to document (#2041)
Browse files Browse the repository at this point in the history
Co-authored-by: philibeaux <aphilibeaux@scaleway.com>
  • Loading branch information
Slashgear and philibea authored Jun 17, 2024
1 parent 577e753 commit ca12d6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sharp-buckets-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scaleway/cookie-consent": patch
---

Cookie consent provider now work on client and server side
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useSegmentIntegrations } from './useSegmentIntegrations'

const COOKIE_PREFIX = '_scw_rgpd'
const HASH_COOKIE = `${COOKIE_PREFIX}_hash`
const IS_CLIENT = typeof document !== 'undefined'

// Appx 13 Months
const CONSENT_MAX_AGE = 13 * 30 * 24 * 60 * 60
Expand Down Expand Up @@ -72,7 +73,7 @@ export const CookieConsentProvider = ({
}>) => {
const [needConsent, setNeedsConsent] = useState(false)
const [cookies, setCookies] = useState<Record<string, string>>(
cookie.parse(document.cookie),
IS_CLIENT ? cookie.parse(document.cookie) : {},
)

const {
Expand Down

0 comments on commit ca12d6d

Please sign in to comment.