diff --git a/apps/api/src/auth/auth.controller.ts b/apps/api/src/auth/auth.controller.ts index c3f3bd0..b28f97b 100644 --- a/apps/api/src/auth/auth.controller.ts +++ b/apps/api/src/auth/auth.controller.ts @@ -29,14 +29,7 @@ export class AuthController { private getTargetUri(req) { const refererURL = new URL(req?.headers?.referer); - const uri = refererURL.searchParams.get('uri'); - if (uri) return uri; - - if (refererURL.pathname.includes('/login')) { - return refererURL.href.split('/login')[1] || '/'; - } - - return '/'; + return refererURL.searchParams.get('uri') || '/'; } private getInvalidPasswordUrl(targetUri: string) { diff --git a/example/nginx.conf b/example/nginx.conf index 19e12dd..81e2488 100644 --- a/example/nginx.conf +++ b/example/nginx.conf @@ -20,7 +20,13 @@ http { listen 80; include /etc/nginx/mime.types; - error_page 401 /login; + error_page 401 @error401; + + location @error401 { + add_header Cache-Control 'no-store, no-cache'; + rewrite ^ /login?uri=$request_uri permanent; + } + location = /auth { internal;