Skip to content

Commit 91517ad

Browse files
authored
Merge pull request #28 from dubinc/www
Account for www. in domain
2 parents cdf01a5 + e4878a8 commit 91517ad

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/script/src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
const HOSTNAME = window.location.hostname;
66

77
const defaultOptions = {
8-
domain: HOSTNAME === 'localhost' ? undefined : `.${HOSTNAME}`,
8+
domain:
9+
HOSTNAME === 'localhost'
10+
? undefined
11+
: // Remove 'www.' from the hostname (because we want to set the cookie on the root domain)
12+
`.${HOSTNAME.replace(/^www\./, '')}`,
913
httpOnly: false,
1014
path: '/',
1115
sameSite: 'Lax',

0 commit comments

Comments
 (0)