diff --git a/apps/api/src/auth/auth.controller.ts b/apps/api/src/auth/auth.controller.ts index 1b55052..feba045 100644 --- a/apps/api/src/auth/auth.controller.ts +++ b/apps/api/src/auth/auth.controller.ts @@ -28,9 +28,14 @@ export class AuthController { private getTargetUri(req) { const refererURL = new URL(req?.headers?.referer); - const targetUri = refererURL.searchParams.get('uri') || '/'; - return targetUri; + const targetUrl = refererURL.searchParams.get('uri') || refererURL.pathname; + + if (!targetUrl || targetUrl.includes('/login')) { + return '/'; + } + + return targetUrl; } private getInvalidPasswordUrl(targetUri: string) {