mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Added framework folder
This commit is contained in:
20
framework/bigcommerce/api/utils/get-cart-cookie.ts
Normal file
20
framework/bigcommerce/api/utils/get-cart-cookie.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { serialize, CookieSerializeOptions } from 'cookie'
|
||||
|
||||
export default function getCartCookie(
|
||||
name: string,
|
||||
cartId?: string,
|
||||
maxAge?: number
|
||||
) {
|
||||
const options: CookieSerializeOptions =
|
||||
cartId && maxAge
|
||||
? {
|
||||
maxAge,
|
||||
expires: new Date(Date.now() + maxAge * 1000),
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
path: '/',
|
||||
sameSite: 'lax',
|
||||
}
|
||||
: { maxAge: -1, path: '/' } // Removes the cookie
|
||||
|
||||
return serialize(name, cartId || '', options)
|
||||
}
|
Reference in New Issue
Block a user