Add query param because of some browsers not sending the referrer

This commit is contained in:
regalijan 2023-10-19 16:51:09 -04:00
parent 9bb2d7396d
commit c7d1e4bd53
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520
2 changed files with 7 additions and 1 deletions

View File

@ -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,
});

View File

@ -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("-", "");