KindeK
Kinde3y ago
14 replies
Chetan Verma

NextJS App Router Error out in middleware

Hello,

I've been working on implementing Kinde Auth within the Next.js app router using middleware. However, I encountered an error after logging in.

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

interface KindeRequest extends NextApiRequest {
  kindeAuth: any; // Replace 'any' with the actual type of kindeAuth if known
}

export default function middleware(req: KindeRequest) {
  return withAuth(req);
}
export const config = {
  matcher: ["/dashboard"],
};


Additionally, I have a backend server where I aim to authenticate requests originating from the client-side Next.js application. Do I need to register a new application on the dashboard? Also, is there a method to authenticate these requests on the server? (The server is written in Nest.js.)
Screenshot_2023-11-30_at_3.17.25_PM.png
Was this page helpful?