fix(next): logout when collection has auth cookies domain set to subdomain #14270
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Adds support for using the
domainproperty from a collection’s auth configuration when deleting cookies.Why
When a cookie is set with a specific domain (for example,
test.vercel.app), the browser will only delete it if the same domain is explicitly provided when callingcookies.delete.Without this, logout operations can fail because the session token cookie remains undeleted.
There is no problem, when collection auth cookie domain config is standard domain (eg.
vercel.app).How?
Get cookie domain from collection auth config and pass it to "cookies.delete" function (if domain set).
Fixes #
There is no issue corresponding to this fix.
I get this bug when deployed payload to vercel without setting custom domain. Vercel set it's own subdomain, and then logout suddenly stopped working.
I had to add workaround like adding
cookies.delete({name:"payload-token",domain: })` next to payload's logoutAction and it started working.