Skip to content

Commit

Permalink
fix(src): pass Next.js more accurate app route metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Xunnamius committed Jan 16, 2024
1 parent 07dc26f commit 09389fe
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,6 @@ const AppRouteRouteModule = findNextjsInternalResolver<
// ? the end-developer's test function runs.
const originalGlobalFetch = globalThis.fetch;

const dummyArgsForAppRouteRouteModule = {
definition: {
kind: 'APP_ROUTE' as any,
page: '/route',
pathname: 'ntarh://testApiHandler',
filename: 'route',
bundlePath: 'app/route'
},
nextConfigOutput: undefined,
resolvedPagePath: 'ntarh://testApiHandler',
userland: {}
};

/**
* @internal
*/
Expand Down Expand Up @@ -451,7 +438,15 @@ export async function testApiHandler<NextResponseJsonType = any>({
}

return new AppRouteRouteModule({
...dummyArgsForAppRouteRouteModule,
definition: {
kind: 'APP_ROUTE' as any,
page: '/route',
pathname: 'ntarh://testApiHandler',
filename: 'route',
bundlePath: 'app/route'
},
nextConfigOutput: undefined,
resolvedPagePath: 'ntarh://testApiHandler',
userland: appHandler
});
}
Expand All @@ -461,13 +456,21 @@ export async function testApiHandler<NextResponseJsonType = any>({
rebindJsonMethodAsSummoner(nextRequest),
{
params: finalParameters,
prerenderManifest: {} as any,
prerenderManifest: {
version: 4,
routes: {},
dynamicRoutes: {},
notFoundRoutes: [],
preview: {} as any
},
renderOpts: {
// ? Next.js poos the bed if we don't include this
experimental: {},
experimental: {
ppr: false
},
// ? Next.js tries to do things it shouldn't unless we add this
supportsDynamicHTML: true
} as any
}
}
);

Expand Down

0 comments on commit 09389fe

Please sign in to comment.