Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix for dev

Blue Mouse67243f679eb1
diff --git a/src/utils/cookie.js b/src/utils/cookie.js
index c6c17d653..f637d5e7a 100644
--- a/src/utils/cookie.js
+++ b/src/utils/cookie.js
@@ -1,5 +1,9 @@
+import { isDevelopment } from '../redux/constants'
+
const COOKIE_DOMAIN = 'swetrix.com'
+const COOKIE_SUFFIX = isDevelopment ? ';' : `; domain=${COOKIE_DOMAIN}; secure`
+
export const getCookie = key => {
const match = document.cookie.match(new RegExp(`(^| )${key}=([^;]+)`))
@@ -11,7 +15,7 @@ export const getCookie = key => {
}
export const setCookie = (key, value, maxAge = 3600, sameSite = 'strict') => {
- document.cookie = `${key}=${value}; max-age=${maxAge}; path=/; domain=${COOKIE_DOMAIN}; SameSite=${sameSite}; secure`
+ document.cookie = `${key}=${value}; max-age=${maxAge}; path=/; SameSite=${sameSite}${COOKIE_SUFFIX}`
}
export const deleteCookie = (key) => {