From c7d1e4bd53d4d41e1dedcd9412dc3260360520dc Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:51:09 -0400 Subject: [PATCH] Add query param because of some browsers not sending the referrer --- functions/api/auth/mobile/login.ts | 2 +- functions/api/auth/oauth.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/functions/api/auth/mobile/login.ts b/functions/api/auth/mobile/login.ts index 0f349ee..c3eeac4 100644 --- a/functions/api/auth/mobile/login.ts +++ b/functions/api/auth/mobile/login.ts @@ -1,7 +1,7 @@ export async function onRequestGet(_context: RequestContext) { return new Response(null, { headers: { - location: "/api/auth/oauth", + location: "/api/auth/oauth?type=mobile", }, status: 302, }); diff --git a/functions/api/auth/oauth.ts b/functions/api/auth/oauth.ts index f644ebe..9029cc2 100644 --- a/functions/api/auth/oauth.ts +++ b/functions/api/auth/oauth.ts @@ -5,6 +5,12 @@ export async function onRequestGet(context: RequestContext) { const referer = request.headers.get("referer"); if (referer) returnPath = new URL(referer).pathname; + else { + const { searchParams } = new URL(context.request.url); + + if (searchParams.get("type") === "mobile") + returnPath = "/api/auth/mobile/token"; + } const state = crypto.randomUUID().replaceAll("-", "");