Skip to content

Commit

Permalink
fix(nextjs): Do not set cookie during cache invalidation (#4478)
Browse files Browse the repository at this point in the history
  • Loading branch information
BRKalow authored Nov 4, 2024
1 parent d728048 commit 5a3eaf7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-dots-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/nextjs': patch
---

Fixes an issue where Next.js cache invalidation was incorrectly setting a cookie.
4 changes: 2 additions & 2 deletions packages/nextjs/src/app-router/server-actions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use server';

import { cookie } from 'ezheaders';
import { getCookies } from 'ezheaders';

// This function needs to be async as we'd like to support next versions in the range of [14.1.2,14.2.0)
// These versions required 'use server' files to export async methods only. This check was later relaxed
// and the async is no longer required in newer next versions.
// ref: https://github.com/vercel/next.js/pull/62821
export async function invalidateCacheAction(): Promise<void> {
await cookie(`__clerk_invalidate_cache_cookie_${Date.now()}`, '');
void (await getCookies()).delete(`__clerk_invalidate_cache_cookie_${Date.now()}`);
}

0 comments on commit 5a3eaf7

Please sign in to comment.