-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Clerk: Error: Clerk: Unable to decrypt request data, this usually means the encryption key is invalid.
#281
Comments
Update (25.05.2025)Manually setting the keys in the middleware produces a different error output: export default clerkMiddleware(
async (auth, req) => {
if (isProtectedRoute(req)) await auth.protect();
},
{
debug: true,
+ secretKey: "mykeyhere",
+ publishableKey: "mykeyhere"
}
);
|
because it's jsonc :)
|
@vicb & @jenslys i am having this issue. The middleware seems to be fine once you supply the
I am on NextJS v15, and the latest opennextjs-cloudflare. So deploying on Vercel and other places work, so now I am pretty sure it's a bug in It seems like route handlers cannot use the clerk functions. |
I'm not sure how to reproduce:
Please add more instructions. |
Did you populate the env with your clerk credentials? |
Please include all required steps in the repro. This will save us time. I think that the issue is in that clerk code: function decryptData(data: string, key: string) {
const decryptedBytes = AES.decrypt(data, key);
const encoded = decryptedBytes.toString(encUtf8);
return JSON.parse(encoded);
}
It returns an object:
So edit: The parameters to decrypt when this fails are: { data: 'U2FsdGVkX19c08J8gVACpKeovMuGqb+LJdB9l18zW8c=', key: '' } |
Linking as this might be related then: |
Testing with the referenced clerk PR did not yield any better results: |
Describe the bug
Been having issue trying to setup a NextJS 15 app with Opennextjs.
It seems to work fine locally when using NextJS 14.2.23 but i get the following error from the middleware when trying to access a protected page on NextJS 15:
Steps to reproduce
Replication of bug:
https://github.com/jenslys/clerk-opennext-bug
Expected behavior
Clerk should be able to decrypt key middleware should work
@opennextjs/cloudflare version
0.3.9
Wrangler version
3.105.0
next info output
Additional context
I have also posted a ticket regarding this in the Clerk discord, linked here, since i am unsure if this is a Clerk issue or Opennextjs issue:
https://discord.com/channels/856971667393609759/1329736080962097162
The text was updated successfully, but these errors were encountered: