Type error
Answered
West African Lion posted this in #help-forum
West African LionOP
I’m running into an issue with my Next.js code. When I try to use the handleError function, I’m getting the following error:
Code route.ts
From what I understand, the handleError function is being used somewhere, but the type is causing a conflict. Does anyone know why this is happening and how I can fix it?
Type '(error: unknown) => Promise<Response>' is not assignable to type 'never'
Code route.ts
import { handlers } from '@/auth';
export const { GET, POST } = handlers;
export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';
export async function handleError(error: unknown) {
console.error('Auth route error:', error);
return new Response('Internal Server Error', { status: 500 });
}
From what I understand, the handleError function is being used somewhere, but the type is causing a conflict. Does anyone know why this is happening and how I can fix it?
Answered by joulev
You can only export certain things from route.ts files and handleError is not one of them. So you have to move that function to another file.
2 Replies
@West African Lion I’m running into an issue with my Next.js code. When I try to use the handleError function, I’m getting the following error:
py
Type '(error: unknown) => Promise<Response>' is not assignable to type 'never'
Code route.ts
ts
import { handlers } from '@/auth';
export const { GET, POST } = handlers;
export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';
export async function handleError(error: unknown) {
console.error('Auth route error:', error);
return new Response('Internal Server Error', { status: 500 });
}
From what I understand, the handleError function is being used somewhere, but the type is causing a conflict. Does anyone know why this is happening and how I can fix it?
You can only export certain things from route.ts files and handleError is not one of them. So you have to move that function to another file.
Answer
West African LionOP
tks