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) {