mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
20 lines
422 B
TypeScript
20 lines
422 B
TypeScript
import { LogoutEndpoint } from "."
|
|
|
|
const logout: LogoutEndpoint['handlers']['logout'] = async ({
|
|
res,
|
|
body: { redirectTo },
|
|
config,
|
|
}) => {
|
|
|
|
// Remove the buyer token
|
|
global.token = null;
|
|
|
|
// Only allow redirects to a relative URL
|
|
if (redirectTo?.startsWith('/')) {
|
|
res.redirect(redirectTo)
|
|
} else {
|
|
res.status(200).json({ data: null })
|
|
}
|
|
}
|
|
|
|
export default logout |