Type error when wrapping Route Handlers
ChristopherTrimboli opened this issue · 1 comments
ChristopherTrimboli commented
next.config.mjs
/** @type {import('next').NextConfig} */
import withVideos from 'next-videos';
import { withAxiom } from 'next-axiom';
const config = {
images: {
domains: [
'flagcdn.com',
'static-cdn.jtvnw.net',
'avatars.steamstatic.com',
'apex-team-logo.s3.us-west-1.amazonaws.com',
'apex-user-profile.s3.us-west-1.amazonaws.com',
],
},
staticPageGenerationTimeout: process.env.NEXT_PUBLIC_ENV === 'local' || process.env.NEXT_PUBLIC_ENV === 'dev' ? 0 : 120, // 2 min
};
export default withVideos(withAxiom(config));
\app\api\cron\apex\route.ts
export const GET = withAxiom((request: AxiomRequest) => {
processNextMatch(database.db, request);
});
error:
.next/types/app/api/cron/apex/route.ts:26:4
Type error: Type 'typeof import("C:/Users/chris/Documents/Github/realm-gg/realm-app/app/api/cron/apex/route")' does not satisfy the constraint '{ GET?: Function | undefined; HEAD?: Function | undefined; OPTIONS?: Function | undefined; POST?: Function | undefined; PUT?: Function | undefined; ... 10 more ...; maxDuration?: number | undefined; }'.
Types of property 'GET' are incompatible.
Type 'NextConfig' is missing the following properties from type 'Function': apply, call, bind, prototype, and 5 more.
24 | maxDuration?: number
25 |
> 26 | }, TEntry, ''>>()
| ^
27 |
28 | // Check the prop type of the entry function
29 | if ('GET' in entry) {
I have tried many variations of next.config plugin chaining, as well as const
and function
in Route Handler... always an issue. Not sure. Please help :)
This is a CRON btw.
ChristopherTrimboli commented
fixed it by adding return NextResponse.json({ success: true });
inside my main handler...
Not sure if this is bug or not... but cheers :)
export const GET = withAxiom((request: AxiomRequest) => {
processNextMatch(database.db, request);
return NextResponse.json({ success: true });
});