Skip to content

Commit

Permalink
Clear all cookies with CognitoIdentityServiceProvider prefix before m…
Browse files Browse the repository at this point in the history
…aking the request
  • Loading branch information
kris-szlapa committed Nov 13, 2024
1 parent ee4ca34 commit 6583861
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/auth_demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6583861

Please sign in to comment.