Skip to content

Commit 37ff8b1

Browse files
fix(remix-server-runtime): fix createCookieFactory with secrets set to undefined (#6056)
Co-authored-by: Michaël De Boey <[email protected]>
1 parent b120b36 commit 37ff8b1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

packages/remix-server-runtime/__tests__/cookies-test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ describe("cookies", () => {
142142
expect(setCookie).not.toEqual(setCookie2);
143143
});
144144

145+
it("makes the default secrets to be an empty array", async () => {
146+
let cookie = createCookie("my-cookie");
147+
148+
expect(cookie.isSigned).toBe(false);
149+
150+
let cookie2 = createCookie("my-cookie2", {
151+
secrets: undefined,
152+
});
153+
154+
expect(cookie2.isSigned).toBe(false);
155+
});
156+
145157
it("makes the default path of cookies to be /", async () => {
146158
let cookie = createCookie("my-cookie");
147159

packages/remix-server-runtime/cookies.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ export const createCookieFactory =
8686
unsign: UnsignFunction;
8787
}): CreateCookieFunction =>
8888
(name, cookieOptions = {}) => {
89-
let { secrets, ...options } = {
90-
secrets: [],
89+
let { secrets = [], ...options } = {
9190
path: "/",
9291
sameSite: "lax" as const,
9392
...cookieOptions,

0 commit comments

Comments
 (0)