diff --git a/packages/storage/src/cookies.ts b/packages/storage/src/cookies.ts index 40bcb269f..e4b5a0fdd 100644 --- a/packages/storage/src/cookies.ts +++ b/packages/storage/src/cookies.ts @@ -146,6 +146,7 @@ export const cookieStorage: StorageWithOptions = addWithOptionsMe return this.getLength(); }, }), + { path: "/" }, ); /** diff --git a/packages/storage/src/tools.ts b/packages/storage/src/tools.ts index a9fef1a34..604a75266 100644 --- a/packages/storage/src/tools.ts +++ b/packages/storage/src/tools.ts @@ -29,13 +29,14 @@ export const addWithOptionsMethod = < W extends AsyncStorage | Storage = S extends AsyncStorageWithOptions ? AsyncStorage : Storage, >( storage: S, + defaultOptions: Partial = {} ): S & { withOptions: (options: O) => W } => { storage.withOptions = (options: O): W => methodKeys.reduce( (wrapped: Partial, key: keyof S) => { if (typeof storage[key] === "function") { (wrapped as any)[key] = (...args: Parameters<(typeof storage)[typeof key]>) => { - args[storage[key].length - 1] = options; + args[storage[key].length - 1] = { ...defaultOptions, ...options }; return storage[key](...args); }; }