From 90bad3a619f7e2d83b12ff10803c3d84448811a4 Mon Sep 17 00:00:00 2001 From: Amol Bhave Date: Fri, 4 Oct 2024 11:33:17 -0500 Subject: [PATCH] Update auth.ts to await `params` in preparation for nextjs 15 In NextJS 15, `params` from routes is now a Promise which must be awaited. Direct access is deprecated and will be removed in future versions. This change is backwards compatible because awaiting on a non-promise returns back the value itself. Without this change we get the following warning: ``` In route /api/auth/[auth0] a param property was accessed directly with `params.auth0`. `params` is now a Promise and should be awaited before accessing properties of the underlying params object. In this version of Next.js direct access to param properties is still supported to facilitate migration but in a future version you will be required to await `params`. If this use is inside an async function await it. If this use is inside a synchronous function then convert the function to async or await it from outside this function and pass the result in. ``` See more details in https://github.com/vercel/next.js/pull/68812 --- src/handlers/auth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/auth.ts b/src/handlers/auth.ts index 222e10ceb..4833a08f5 100644 --- a/src/handlers/auth.ts +++ b/src/handlers/auth.ts @@ -207,7 +207,7 @@ export default function handlerFactory({ const appRouteHandlerFactory: (customHandlers: ApiHandlers, onError?: AppRouterOnError) => AppRouteHandlerFn = (customHandlers, onError) => async (req: NextRequest, ctx) => { const { params } = ctx; - let route = params.auth0; + let route = (await params).auth0; if (Array.isArray(route)) { let otherRoutes;