Welcome to the Kinde community.

A
A
A
M
T

Next.js 14.0.3 Middleware TypeError

Subject: Assistance Needed with TypeScript Error in Kind Auth Implementation

Hey there! πŸ‘‹

I hope this message finds you well. I'm currently using Kind Auth for the first time, and I've encountered a TypeScript error while trying to access a protected route.

Following the Next.js starter kit, I've set up the protected route at /dashboard. However, every time I attempt to access it, I'm confronted with the following error:

Server Error
TypeError: Cannot read properties of undefined (reading 'value')

Plain Text
  3 |
  4 | export default function middleware(req: NextRequest) {
> 5 | return withAuth(req);
    |                ^
  6 | }
  7 |
  8 | export const config = {


Interestingly, despite this error, the authentication seems to be working fine. The user exists and is successfully populated in the database.

I'd greatly appreciate any guidance or assistance you can provide in resolving this issue.

Thanks a bunch! πŸ™

Github Repo: https://github.com/ruymon/revivi/tree/5ced50b82d94c4c329fde3709701746cf6ea2355
R
O
f
11 comments
Hi @Ruyy,
Thanks for flagging that your issue here is a duplicate of https://discord.com/channels/1070212618549219328/1179721063450546206
I can see in your repo that you are using the Kinde NextJS SDK v2.0.10
As mentioned in https://discord.com/channels/1070212618549219328/1179721063450546206, our NextJS expert teammate is looking into this issue. I will get back to you once we have more information.
Hey @Ruyy,
As mentioned in https://discord.com/channels/1070212618549219328/1179721063450546206/1179721063450546206, you should be able to use the middleware in NextJS App Router v1 to achieve what you are after: https://kinde.com/docs/developer-tools/nextjs-sdkv1/#protecting-pages

Please let me know if you come across any other issues.
Hey @Ruyy,
As mentioned in https://discord.com/channels/1070212618549219328/1179721063450546206, there is a new version of the NextJS SDK v2.0.11 that fixed this middleware issue.

Please let us know if you are still experiencing any issues.
Hey, @Oli - Kinde !

I confess that I had changed the auth in that project cuz I was not sure how long till the issue was fixed but you guys are blazing fast πŸ˜‚
We work at lightning speed here ⚑ , we don't let issues like this get dust on them.
Add a reply
Sign up and join the conversation on Discord
Join