kinde-auth-nextjs icon indicating copy to clipboard operation
kinde-auth-nextjs copied to clipboard

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

Open oasaleh opened this issue 9 months ago • 2 comments

Prerequisites

  • [X] I have searched the repository’s issues and Kinde community to ensure my issue isn’t a duplicate
  • [X] I have checked the latest version of the library to replicate my issue
  • [X] I have read the contributing guidelines
  • [X] I agree to the terms within the code of conduct

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

oasaleh avatar Apr 26 '24 15:04 oasaleh

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

50BytesOfJohn avatar Apr 28 '24 07:04 50BytesOfJohn

released 2.2.5-1 which should resolve this issue

peterphanouvong avatar May 01 '24 00:05 peterphanouvong