From 2027447eab0121c758932eb967cd603bcdc08e3e Mon Sep 17 00:00:00 2001 From: zomars Date: Tue, 6 Sep 2022 19:18:47 -0600 Subject: [PATCH] Takes you back to referer page on v2 opt-in --- apps/web/pages/api/v2-opt-in.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/web/pages/api/v2-opt-in.ts b/apps/web/pages/api/v2-opt-in.ts index cb2e7b8083..cd9fcca0b6 100644 --- a/apps/web/pages/api/v2-opt-in.ts +++ b/apps/web/pages/api/v2-opt-in.ts @@ -15,7 +15,12 @@ async function handler(req: NextApiRequest, res: NextApiResponse): Pro res.setHeader("Set-Cookie", "calcom-v2-early-access=1; Path=/"); } - res.redirect("/"); + let redirectUrl = "/"; + + // We take you back where you came from if possible + if (typeof req.headers["referer"] === "string") redirectUrl = req.headers["referer"]; + + res.redirect(redirectUrl); } export default defaultHandler({