mirror of
https://github.com/vercel/commerce.git
synced 2025-03-30 17:05:52 +00:00
23 lines
505 B
TypeScript
23 lines
505 B
TypeScript
import createApiHandler, {
|
|
ShopifyApiHandler,
|
|
} from '../utils/create-api-handler'
|
|
|
|
import { SWELL_CHECKOUT_URL_COOKIE } from '../../const'
|
|
|
|
import { getConfig } from '..'
|
|
|
|
const checkoutApi: ShopifyApiHandler<any> = async (req, res, config) => {
|
|
config = getConfig()
|
|
|
|
const { cookies } = req
|
|
const checkoutUrl = cookies[SWELL_CHECKOUT_URL_COOKIE]
|
|
|
|
if (checkoutUrl) {
|
|
res.redirect(checkoutUrl)
|
|
} else {
|
|
res.redirect('/cart')
|
|
}
|
|
}
|
|
|
|
export default createApiHandler(checkoutApi, {}, {})
|