Skip to content

Commit f4ed2e0

Browse files
authored
fix: set max-age default cookie option to 400 days (#54)
Some browsers didn't like the large number used by the `Max-Age` default cookie option, causing weird behavior. It's now set to [400 days](https://developer.chrome.com/blog/cookie-max-age-expires).
1 parent a48fe6f commit f4ed2e0

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

src/__snapshots__/createServerClient.spec.ts.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ exports[`createServerClient > use cases > should refresh session correctly as ty
3434
"name": "custom-storage-key.0",
3535
"options": {
3636
"httpOnly": false,
37-
"maxAge": 31536000000,
37+
"maxAge": 34560000,
3838
"path": "/",
3939
"sameSite": "lax",
4040
},
@@ -44,7 +44,7 @@ exports[`createServerClient > use cases > should refresh session correctly as ty
4444
"name": "custom-storage-key.1",
4545
"options": {
4646
"httpOnly": false,
47-
"maxAge": 31536000000,
47+
"maxAge": 34560000,
4848
"path": "/",
4949
"sameSite": "lax",
5050
},
@@ -75,7 +75,7 @@ exports[`createServerClient > use cases > should refresh session correctly as ty
7575
"name": "sb-project-ref-auth-token.0",
7676
"options": {
7777
"httpOnly": false,
78-
"maxAge": 31536000000,
78+
"maxAge": 34560000,
7979
"path": "/",
8080
"sameSite": "lax",
8181
},
@@ -85,7 +85,7 @@ exports[`createServerClient > use cases > should refresh session correctly as ty
8585
"name": "sb-project-ref-auth-token.1",
8686
"options": {
8787
"httpOnly": false,
88-
"maxAge": 31536000000,
88+
"maxAge": 34560000,
8989
"path": "/",
9090
"sameSite": "lax",
9191
},
@@ -100,7 +100,7 @@ exports[`createServerClient > use cases > should set PKCE code verifier correctl
100100
"name": "custom-storage-key-code-verifier",
101101
"options": {
102102
"httpOnly": false,
103-
"maxAge": 31536000000,
103+
"maxAge": 34560000,
104104
"path": "/",
105105
"sameSite": "lax",
106106
},
@@ -115,7 +115,7 @@ exports[`createServerClient > use cases > should set PKCE code verifier correctl
115115
"name": "sb-project-ref-auth-token-code-verifier",
116116
"options": {
117117
"httpOnly": false,
118-
"maxAge": 31536000000,
118+
"maxAge": 34560000,
119119
"path": "/",
120120
"sameSite": "lax",
121121
},
@@ -140,7 +140,7 @@ exports[`createServerClient > use cases > should set exchange PKCE code for sess
140140
"name": "custom-storage-key.0",
141141
"options": {
142142
"httpOnly": false,
143-
"maxAge": 31536000000,
143+
"maxAge": 34560000,
144144
"path": "/",
145145
"sameSite": "lax",
146146
},
@@ -150,7 +150,7 @@ exports[`createServerClient > use cases > should set exchange PKCE code for sess
150150
"name": "custom-storage-key.1",
151151
"options": {
152152
"httpOnly": false,
153-
"maxAge": 31536000000,
153+
"maxAge": 34560000,
154154
"path": "/",
155155
"sameSite": "lax",
156156
},
@@ -195,7 +195,7 @@ exports[`createServerClient > use cases > should set exchange PKCE code for sess
195195
"name": "sb-project-ref-auth-token.0",
196196
"options": {
197197
"httpOnly": false,
198-
"maxAge": 31536000000,
198+
"maxAge": 34560000,
199199
"path": "/",
200200
"sameSite": "lax",
201201
},
@@ -205,7 +205,7 @@ exports[`createServerClient > use cases > should set exchange PKCE code for sess
205205
"name": "sb-project-ref-auth-token.1",
206206
"options": {
207207
"httpOnly": false,
208-
"maxAge": 31536000000,
208+
"maxAge": 34560000,
209209
"path": "/",
210210
"sameSite": "lax",
211211
},

src/utils/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ export const DEFAULT_COOKIE_OPTIONS: CookieOptions = {
44
path: "/",
55
sameSite: "lax",
66
httpOnly: false,
7-
maxAge: 60 * 60 * 24 * 365 * 1000,
7+
// https://developer.chrome.com/blog/cookie-max-age-expires
8+
// https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html#name-cookie-lifetime-limits
9+
maxAge: 400 * 24 * 60 * 60,
810
};

0 commit comments

Comments
 (0)