From 68e5c0fac449954d7d05c080c83b5b69ee0564d7 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Thu, 15 Jan 2026 19:18:18 -0700 Subject: [PATCH] Cleanup params --- index.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/index.tsx b/index.tsx index 2882a3d..0ad39af 100644 --- a/index.tsx +++ b/index.tsx @@ -6,6 +6,26 @@ import { Toaster } from 'react-hot-toast'; import App from './App'; import { oidcConfig } from './src/config/oidc'; +// Clean up stale OAuth params on page load (e.g., after logout redirect) +// This prevents "No matching state found in storage" errors +const cleanupStaleOAuthParams = () => { + const params = new URLSearchParams(window.location.search); + const hasOAuthParams = params.has('code') || params.has('state'); + + if (hasOAuthParams) { + const state = params.get('state'); + // Check if there's a matching state in storage + const hasMatchingState = state && localStorage.getItem(`oidc.${state}`); + + if (!hasMatchingState) { + // Stale params - clean them up + window.history.replaceState({}, document.title, window.location.pathname); + } + } +}; + +cleanupStaleOAuthParams(); + const rootElement = document.getElementById('root'); if (!rootElement) { throw new Error("Could not find root element to mount to");