diff --git a/packages/auth_demo/src/App.tsx b/packages/auth_demo/src/App.tsx index 7eca184..26c002d 100644 --- a/packages/auth_demo/src/App.tsx +++ b/packages/auth_demo/src/App.tsx @@ -65,12 +65,25 @@ function App() { } } + const clearCognitoCookies = () => { + const cookies = document.cookie.split("; ") + cookies.forEach(cookie => { + if (cookie.startsWith("CognitoIdentityServiceProvider")) { + // Remove the cookie by setting its expiration date to the past + document.cookie = `${cookie.split("=")[0]}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;` + } + }) + } + const fetchPrescriptionData = async () => { if (!prescriptionId) { setError('Please enter a Prescription ID.') return } + // Clear all cookies with 'CognitoIdentityServiceProvider' prefix before making the request + clearCognitoCookies() + setLoading(true) setPrescriptionData(null) setError(null)