Welcome to the Kinde community

Updated last year

Invalid configuration "GET"

Plain Text
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 Handlers

https://kinde.com/docs/developer-tools/nextjs-sdk/#set-up-kinde-auth-route-handlers

Plain Text
import {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:

Plain Text
export const GET = handleAuth() as any


or

Plain Text
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?
A
s
O
7 comments
Thanks for raising this @saM69420 and also detailing a detailed solution. A PR will be made tonight regarding this issue.
Well in the next 4 hrs
Thank you, is it better to open issues like this here or on GitHub?
Hi @saM69420,
We have released a new version of the NextJS v2.0.9: https://www.npmjs.com/package/@kinde-oss/kinde-auth-nextjs
Are you able to update to the this latest version and see if your issue still exists (without the temporary solution)?
And yeh it's preferred to raise an issue on the GitHub repo, but posting here in Discord is fine too.
seems to be working great. thank you
Good to hear!
Please don't hesitate to open a new support thread if you come across anymore issues.
Add a reply
Sign up and join the conversation on Discord