Skip to content

Commit 7d73126

Browse files
committed
fix: force check slug variable on forked checkout
1 parent 51dbc2f commit 7d73126

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

pages/api/settings.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function getTokenInfo(accessToken: string) {
130130
}
131131

132132
export default async (req: NextApiRequest, res: NextApiResponse) => {
133-
const { NODE_ENV, DOMAIN, HOSTED } = process.env
133+
const { NODE_ENV, DOMAIN, HOSTED, NEXT_PUBLIC_SLUG } = process.env
134134
const accessToken = req.query.accessToken as string
135135
const orderId = req.query.orderId as string
136136

@@ -151,7 +151,9 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
151151
return invalidateCheckout()
152152
}
153153

154-
const subdomain = req.headers.host?.split(":")[0].split(".")[0]
154+
const subdomain = HOSTED
155+
? req.headers.host?.split(":")[0].split(".")[0]
156+
: NEXT_PUBLIC_SLUG
155157

156158
const { slug, kind, isTest } = getTokenInfo(accessToken)
157159

@@ -161,7 +163,6 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
161163

162164
if (
163165
isProduction(NODE_ENV) &&
164-
!!HOSTED &&
165166
(subdomain !== slug || kind !== "sales_channel")
166167
) {
167168
return invalidateCheckout()

0 commit comments

Comments
 (0)