#invalid export error while deploying project to vercel

1 messages · Page 1 of 1 (latest)

torn copper
#

error: Failed to compile.
src/app/api/auth/[kindeAuth]/route.ts
Type error: Route "src/app/api/auth/[kindeAuth]/route.ts" has an invalid export:
"Promise<void | Response | ((req: Request | NextApiRequest, res: Response | NextApiResponse) => Promise<...>)>" is not a valid GET return type:
Expected "void | Response | Promise<void | Response>", got "Promise<void | Response | ((req: Request | NextApiRequest, res: Response | NextApiResponse) => Promise<void | Response | NextApiResponse<...>>)>".
Expected "Promise<void | Response>", got "Promise<void | Response | ((req: Request | NextApiRequest, res: Response | NextApiResponse) => Promise<void | Response | NextApiResponse<...>>)>".
Expected "void | Response", got "void | Response | ((req: Request | NextApiRequest, res: Response | NextApiResponse) => Promise<void | Response | NextApiResponse<...>>)".
Expected "void | Response", got "(req: Request | NextApiRequest, res: Response | NextApiResponse) => Promise<void | Response | NextApiResponse<any>>".
error: script "build" exited with code 1 (SIGHUP)
Error: Command "bun run build" exited with 1

code in src/app/api/auth/[kindeAuth]/route.ts
import { handleAuth } from '@kinde-oss/kinde-auth-nextjs/server';
import { NextRequest } from 'next/server';

export async function GET(request: NextRequest, { params }: any) {
const endpoint = params.kindeAuth;
return handleAuth(request, endpoint);
}

cyan brambleBOT
#

Hi @torn copper. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Hmm, I don't know enough to give you a confident answer yet.

However, based on the information provided in the extracts, it seems that the error message is indicating that the return type of the GET function in your route.ts file is not matching the expected type. The Next.js framework expects a GET function to return either void, a Response object, or a Promise that resolves to void or Response.

The error message suggests that the handleAuth function you are using might be returning a value that includes a function type, which is not expected by Next.js for a GET handler.

To resolve this issue, you should ensure that the handleAuth function returns a value that is compatible with the expected return types for a GET function in Next.js. If handleAuth is a third-party function from @kinde-oss/kinde-auth-nextjs/server, you may need to check its documentation to understand what it returns and how to handle its response correctly.

Unfortunately, the extracts provided do not include information about the handleAuth function or the @kinde-oss/kinde-auth-nextjs/server package, so I cannot provide a specific solution to the error.

For more information on how to handle API routes in Next.js, you can refer to the Next.js documentation on API Routes (https://nextjs.org/docs/api-routes/introduction).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: