Cleanup params

This commit is contained in:
Joey Yakimowich-Payne 2026-01-15 19:18:18 -07:00
commit 68e5c0fac4
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1

View file

@ -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");