Unverified Commit 84e47b82 authored by Vincent Voyer's avatar Vincent Voyer Committed by GitHub

docs(examples): with-iron-session logout must be called via POST (#22240)

1. Logout is better called in a POST request (avoids caching in most situations + avoids weird CSRF "logout attacks", i.e. can't be logged out by clicking on an email link)
2. We should wait for logout to complete before mutating the user, otherwise some weird race conditions might prevent swr to catch the right logged out state
parent 1f5f0d31
......@@ -43,7 +43,10 @@ const Header = () => {
href="/api/logout"
onClick={async (e) => {
e.preventDefault()
await mutateUser(fetchJson('/api/logout'))
mutateUser(
await fetchJson('/api/logout', { method: 'POST' }),
false
)
router.push('/login')
}}
>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment