Type error: Route "src/app/api/auth/[kindeAuth]/route.ts" does not match the required types of a Next.js Route.
Invalid configuration "GET":
Expected "Function | undefined", got "Promise<void | Response> | ((req: NextApiRequest | Request, res: Response | NextApiResponse) => Promise<...>)".
Linting and checking validity of types ...error: script "build" exited with code 1 (SIGHUP)
This was already mentioned in support (1174134934265397289) but I think it deserves a bug report thread.
---
Set up Kinde Auth Route Handlershttps://kinde.com/docs/developer-tools/nextjs-sdk/#set-up-kinde-auth-route-handlersimport {handleAuth} from "@kinde-oss/kinde-auth-nextjs/server";
export const GET = handleAuth();
This code causes the error when you try to build a typescript next.js app.
The reason is that the default export in
handlers/auth.js
can return a promise for backwards compatibility, but won't ever return a promise when called with no params like we are here.
https://github.com/kinde-oss/kinde-auth-nextjs/blob/main/src/handlers/auth.js---
Temporary Solution:export const GET = handleAuth() as any
or
export const GET = handleAuth() as (req: Request, res: Response) => Promise<void>
Not sure about long term solutions. Does JSDoc work with overloading functions and typescript?