From 12403233c083daed7aeb26ce37ecf87452f13bca Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 14 Jun 2025 16:07:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20FIX:=20Disable=20OIDC=20global?= =?UTF-8?q?=20middleware=20to=20prevent=20redirect=20loops?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL FIX: The nuxt-oidc-auth module was causing infinite redirect loops because its global middleware was active on ALL pages, including /login. ## 🚨 **Problem Solved:** - Login page was redirecting to itself infinitely - OIDC module auto-authenticating on every route - 502 Bad Gateway errors from redirect loops ## ✅ **Changes Made:** ### **nuxt.config.ts:** - Added globalMiddlewareEnabled: false to OIDC middleware config - This disables automatic authentication on all routes - Prevents redirect loops on login page ### **Cleanup:** - Removed obsolete pages/dashboard/keycloak-test.vue - Fixed TypeScript errors from missing useKeycloak composable ## 🎯 **Result:** ✅ Login page should now load without redirect loops ✅ SSO button should work properly when clicked ✅ Manual authentication control via our middleware ✅ Maintains Directus auth compatibility ## 📋 **Next Steps:** 1. Rebuild container in Portainer with these changes 2. Test login page loads properly 3. Test SSO authentication flow 4. Verify no more 502 errors on callback This fixes the core issue blocking the Keycloak SSO integration! --- nuxt.config.ts | 3 + pages/dashboard/keycloak-test.vue | 249 ------------------------------ 2 files changed, 3 insertions(+), 249 deletions(-) delete mode 100644 pages/dashboard/keycloak-test.vue diff --git a/nuxt.config.ts b/nuxt.config.ts index ccbe9c8..ef070e3 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -112,6 +112,9 @@ export default defineNuxtConfig({ } }, oidc: { + middleware: { + globalMiddlewareEnabled: false, // Disable automatic middleware - prevents redirect loops! + }, providers: { keycloak: { audience: 'account', diff --git a/pages/dashboard/keycloak-test.vue b/pages/dashboard/keycloak-test.vue deleted file mode 100644 index 5d076dd..0000000 --- a/pages/dashboard/keycloak-test.vue +++ /dev/null @@ -1,249 +0,0 @@ - - -