kinde-oss / kinde-auth-nextjs

Kinde NextJS SDK - authentication for server rendered apps
https://kinde.com/docs/developer-tools/nextjs-sdk/
MIT License
132 stars 17 forks source link

Bug: middleware with withAuth does not work: TypeError: Cannot read properties of undefined (reading 'value') #153

Closed oasaleh closed 1 month ago

oasaleh commented 2 months ago

Prerequisites

Describe the issue

A simple app with one protected page using middleware does not work

import { withAuth } from "@kinde-oss/kinde-auth-nextjs/middleware";

export default withAuth(async function middleware(req) {
  console.log("look at me", req.kindeAuth);
});

export const config = {
  matcher: ["/admin"],
};

however, when doing this, it works

import { withAuth } from "@kinde-oss/kinde-auth-nextjs/middleware";
export default function middleware(req) {
  return withAuth(req);
}
export const config = {
  matcher: ["/admin"],
};

This is the error I'm getting

image

I don't have any special setup in-place. Just a public page with a <Link> to a protected page.

Library URL

https://github.com/kinde-oss/kinde-auth-nextjs

Library version

2.2.4

Operating system(s)

macOS

Operating system version(s)

14.4.1

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

50BytesOfJohn commented 2 months ago

Hey, Seems like it can be the same issue happened to me: https://github.com/kinde-oss/kinde-auth-nextjs/issues/151

peterphanouvong commented 2 months ago

released 2.2.5-1 which should resolve this issue