1
0
mirror of https://github.com/vercel/commerce.git synced 2025-07-27 20:21:22 +00:00
Files
.vscode
assets
components
config
docs
framework
bigcommerce
api
cart
catalog
customer
customers
handlers
get-logged-in-customer.ts
login.ts
logout.ts
signup.ts
index.ts
login.ts
logout.ts
signup.ts
definitions
fragments
operations
utils
wishlist
checkout.ts
index.ts
auth
cart
common
customer
lib
product
scripts
types
wishlist
.env.template
README.md
commerce.config.json
fetcher.ts
index.tsx
next.config.js
provider.ts
schema.d.ts
schema.graphql
commerce
shopify
lib
pages
public
.editorconfig
.env.template
.gitignore
.prettierignore
.prettierrc
README.md
codegen.json
commerce.config.json
global.d.ts
license.md
next-env.d.ts
next.config.js
package.json
postcss.config.js
tailwind.config.js
tsconfig.json
yarn.lock
commerce/framework/bigcommerce/api/customers/handlers/logout.ts
2020-12-29 19:14:49 -05:00

24 lines
514 B
TypeScript

import { serialize } from 'cookie'
import { LogoutHandlers } from '../logout'
const logoutHandler: LogoutHandlers['logout'] = async ({
res,
body: { redirectTo },
config,
}) => {
// Remove the cookie
res.setHeader(
'Set-Cookie',
serialize(config.customerCookie, '', { maxAge: -1, path: '/' })
)
// Only allow redirects to a relative URL
if (redirectTo?.startsWith('/')) {
res.redirect(redirectTo)
} else {
res.status(200).json({ data: null })
}
}
export default logoutHandler