From fb1ada5a73a8ab2e9acdade409b208cd83aebb0d Mon Sep 17 00:00:00 2001 From: Chika Date: Tue, 6 Dec 2022 10:54:26 +0300 Subject: [PATCH] apps/api: fix get redirect uri --- apps/api/src/auth/auth.controller.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/api/src/auth/auth.controller.ts b/apps/api/src/auth/auth.controller.ts index feba045..c3f3bd0 100644 --- a/apps/api/src/auth/auth.controller.ts +++ b/apps/api/src/auth/auth.controller.ts @@ -29,13 +29,14 @@ export class AuthController { private getTargetUri(req) { const refererURL = new URL(req?.headers?.referer); - const targetUrl = refererURL.searchParams.get('uri') || refererURL.pathname; + const uri = refererURL.searchParams.get('uri'); + if (uri) return uri; - if (!targetUrl || targetUrl.includes('/login')) { - return '/'; + if (refererURL.pathname.includes('/login')) { + return refererURL.href.split('/login')[1] || '/'; } - return targetUrl; + return '/'; } private getInvalidPasswordUrl(targetUri: string) {