From 6ce1b36e1adda47533f0035c3bfb044e1d6c5cbc Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Wed, 20 Aug 2025 21:14:33 +1000 Subject: [PATCH 01/22] fix(next): add optional params arg to GET handler for Next 15.2 compatibility --- packages/next/src/routes/graphql/playground.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/routes/graphql/playground.ts b/packages/next/src/routes/graphql/playground.ts index f7c7541b682..5fec2a015db 100644 --- a/packages/next/src/routes/graphql/playground.ts +++ b/packages/next/src/routes/graphql/playground.ts @@ -1,7 +1,7 @@ import { renderPlaygroundPage } from 'graphql-playground-html' import { createPayloadRequest, type SanitizedConfig } from 'payload' -export const GET = (config: Promise) => async (request: Request) => { +export const GET = (config: Promise) => async (request: Request, params?: any) => { const req = await createPayloadRequest({ config, request, From 5c990ba25c7c88031efd112a6837a842d2d2f56c Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Wed, 20 Aug 2025 21:16:48 +1000 Subject: [PATCH 02/22] fix(next): add optional params arg to GET handler for Next 15.2 compatibility --- packages/next/src/routes/graphql/handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/routes/graphql/handler.ts b/packages/next/src/routes/graphql/handler.ts index c2b55a45f9e..2142997dffc 100644 --- a/packages/next/src/routes/graphql/handler.ts +++ b/packages/next/src/routes/graphql/handler.ts @@ -96,7 +96,7 @@ export const getGraphql = async (config: Promise | SanitizedCon } export const POST = - (config: Promise | SanitizedConfig) => async (request: Request) => { + (config: Promise | SanitizedConfig) => async (request: Request, params?: any) => { const originalRequest = request.clone() const req = await createPayloadRequest({ canSetHeaders: true, From 713e0e221ddb4de00b54f5ad48028413bfdaaa98 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Wed, 20 Aug 2025 21:24:02 +1000 Subject: [PATCH 03/22] fix(next): make handlerBuilder args optional for Next 15.2 route handlers --- packages/next/src/routes/rest/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/routes/rest/index.ts b/packages/next/src/routes/rest/index.ts index 533c639aef1..e7630994f59 100644 --- a/packages/next/src/routes/rest/index.ts +++ b/packages/next/src/routes/rest/index.ts @@ -8,7 +8,7 @@ const handlerBuilder = (config: Promise | SanitizedConfig) => async ( request: Request, - args: { + args?: { params: Promise<{ slug: string[] }> }, ): Promise => { From 0adc383e7926969e19b9849f8347402198194807 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Wed, 20 Aug 2025 21:34:51 +1000 Subject: [PATCH 04/22] fix(next): args.params guard to prevent runtime errors when handlers are used on static routes. --- packages/next/src/routes/rest/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/routes/rest/index.ts b/packages/next/src/routes/rest/index.ts index e7630994f59..8a01404d4e0 100644 --- a/packages/next/src/routes/rest/index.ts +++ b/packages/next/src/routes/rest/index.ts @@ -30,7 +30,7 @@ const handlerBuilder = initedOGEndpoint = true - const awaitedParams = await args.params + const awaitedParams = args ? await args.params : undefined const response = await handleEndpoints({ config, From 9e5507261ceb10babceaaa93aef9f0850f87953f Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:28:02 +1000 Subject: [PATCH 05/22] fix(nextjs): update REST and handlerBuilder params for Next 15.2 compatibility --- packages/next/src/routes/rest/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/next/src/routes/rest/index.ts b/packages/next/src/routes/rest/index.ts index 8a01404d4e0..5fc5c17d0ff 100644 --- a/packages/next/src/routes/rest/index.ts +++ b/packages/next/src/routes/rest/index.ts @@ -9,7 +9,7 @@ const handlerBuilder = async ( request: Request, args?: { - params: Promise<{ slug: string[] }> + params: Promise<{ slug?: string[] }> }, ): Promise => { const awaitedConfig = await config @@ -31,11 +31,12 @@ const handlerBuilder = initedOGEndpoint = true const awaitedParams = args ? await args.params : undefined + const slugArr = awaitedParams?.slug ?? [] const response = await handleEndpoints({ config, - path: awaitedParams - ? `${awaitedConfig.routes.api}/${awaitedParams.slug.join('/')}` + path: slugArr.length + ? `${awaitedConfig.routes.api}/${slugArr.join('/')}` : undefined, request, }) From c2355e317adfe2b0311ea012ffd077ce08fef42a Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:39:06 +1000 Subject: [PATCH 06/22] fix(graphql): add proper type for Next.js route params in POST handler --- packages/next/src/routes/graphql/handler.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/next/src/routes/graphql/handler.ts b/packages/next/src/routes/graphql/handler.ts index 2142997dffc..0e86c396501 100644 --- a/packages/next/src/routes/graphql/handler.ts +++ b/packages/next/src/routes/graphql/handler.ts @@ -96,7 +96,9 @@ export const getGraphql = async (config: Promise | SanitizedCon } export const POST = - (config: Promise | SanitizedConfig) => async (request: Request, params?: any) => { + (config: Promise | SanitizedConfig) => async (request: Request, _params?: Promise<{ slug?: string[] }>) => { + void _params + const originalRequest = request.clone() const req = await createPayloadRequest({ canSetHeaders: true, From d713e31db0404c32e454d96fb9f10ddda97a9ceb Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:44:03 +1000 Subject: [PATCH 07/22] fix(graphql-playground): type params as Next.js route context in GET handler --- packages/next/src/routes/graphql/playground.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/routes/graphql/playground.ts b/packages/next/src/routes/graphql/playground.ts index 5fec2a015db..7b34356b044 100644 --- a/packages/next/src/routes/graphql/playground.ts +++ b/packages/next/src/routes/graphql/playground.ts @@ -1,7 +1,7 @@ import { renderPlaygroundPage } from 'graphql-playground-html' import { createPayloadRequest, type SanitizedConfig } from 'payload' -export const GET = (config: Promise) => async (request: Request, params?: any) => { +export const GET = (config: Promise) => async (request: Request, _params?: Promise<{ slug?: string[] }>) => { const req = await createPayloadRequest({ config, request, From c62032fe4231c9fd28af2778672020764d0756c7 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:44:42 +1000 Subject: [PATCH 08/22] fix(graphql): add proper type for Next.js route params in POST handler --- packages/next/src/routes/graphql/handler.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/next/src/routes/graphql/handler.ts b/packages/next/src/routes/graphql/handler.ts index 0e86c396501..f125408afb1 100644 --- a/packages/next/src/routes/graphql/handler.ts +++ b/packages/next/src/routes/graphql/handler.ts @@ -97,8 +97,6 @@ export const getGraphql = async (config: Promise | SanitizedCon export const POST = (config: Promise | SanitizedConfig) => async (request: Request, _params?: Promise<{ slug?: string[] }>) => { - void _params - const originalRequest = request.clone() const req = await createPayloadRequest({ canSetHeaders: true, From 56f0c80abfdf3677b7fae683683abd5e386bba4e Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:48:28 +1000 Subject: [PATCH 09/22] fix(template): update GET handler to use NextRequest for Next.js 15.2 --- .../src/app/(frontend)/next/preview/route.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/templates/with-vercel-website/src/app/(frontend)/next/preview/route.ts b/templates/with-vercel-website/src/app/(frontend)/next/preview/route.ts index 515c79edb68..fb25525b533 100644 --- a/templates/with-vercel-website/src/app/(frontend)/next/preview/route.ts +++ b/templates/with-vercel-website/src/app/(frontend)/next/preview/route.ts @@ -3,18 +3,11 @@ import { getPayload } from 'payload' import { draftMode } from 'next/headers' import { redirect } from 'next/navigation' +import { NextRequest } from "next/server" import configPromise from '@payload-config' -export async function GET( - req: { - cookies: { - get: (name: string) => { - value: string - } - } - } & Request, -): Promise { +export async function GET(req: NextRequest): Promise { const payload = await getPayload({ config: configPromise }) const { searchParams } = new URL(req.url) From 667aae26a25db9ad873ed877866668f217095934 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:50:18 +1000 Subject: [PATCH 10/22] fix(template): update GET handler to use NextRequest for Next.js 15.2 --- .../website/src/app/(frontend)/next/preview/route.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/templates/website/src/app/(frontend)/next/preview/route.ts b/templates/website/src/app/(frontend)/next/preview/route.ts index 515c79edb68..fb25525b533 100644 --- a/templates/website/src/app/(frontend)/next/preview/route.ts +++ b/templates/website/src/app/(frontend)/next/preview/route.ts @@ -3,18 +3,11 @@ import { getPayload } from 'payload' import { draftMode } from 'next/headers' import { redirect } from 'next/navigation' +import { NextRequest } from "next/server" import configPromise from '@payload-config' -export async function GET( - req: { - cookies: { - get: (name: string) => { - value: string - } - } - } & Request, -): Promise { +export async function GET(req: NextRequest): Promise { const payload = await getPayload({ config: configPromise }) const { searchParams } = new URL(req.url) From 99cdb5dad5840b78063d4d85ab89dda67f3f7c53 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Wed, 20 Aug 2025 21:14:33 +1000 Subject: [PATCH 11/22] fix(next): add optional params arg to GET handler for Next 15.5 compatibility --- packages/next/src/routes/graphql/playground.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/routes/graphql/playground.ts b/packages/next/src/routes/graphql/playground.ts index f7c7541b682..5fec2a015db 100644 --- a/packages/next/src/routes/graphql/playground.ts +++ b/packages/next/src/routes/graphql/playground.ts @@ -1,7 +1,7 @@ import { renderPlaygroundPage } from 'graphql-playground-html' import { createPayloadRequest, type SanitizedConfig } from 'payload' -export const GET = (config: Promise) => async (request: Request) => { +export const GET = (config: Promise) => async (request: Request, params?: any) => { const req = await createPayloadRequest({ config, request, From 1849c51718701164b03a07d7ec9c5de13403500f Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Wed, 20 Aug 2025 21:16:48 +1000 Subject: [PATCH 12/22] fix(next): add optional params arg to GET handler for Next 15.5 compatibility --- packages/next/src/routes/graphql/handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/routes/graphql/handler.ts b/packages/next/src/routes/graphql/handler.ts index c2b55a45f9e..2142997dffc 100644 --- a/packages/next/src/routes/graphql/handler.ts +++ b/packages/next/src/routes/graphql/handler.ts @@ -96,7 +96,7 @@ export const getGraphql = async (config: Promise | SanitizedCon } export const POST = - (config: Promise | SanitizedConfig) => async (request: Request) => { + (config: Promise | SanitizedConfig) => async (request: Request, params?: any) => { const originalRequest = request.clone() const req = await createPayloadRequest({ canSetHeaders: true, From 97711a4ea945a1593f17af10c019f288876c3c07 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Wed, 20 Aug 2025 21:24:02 +1000 Subject: [PATCH 13/22] fix(next): make handlerBuilder args optional for Next 15.5 route handlers --- packages/next/src/routes/rest/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/routes/rest/index.ts b/packages/next/src/routes/rest/index.ts index 533c639aef1..e7630994f59 100644 --- a/packages/next/src/routes/rest/index.ts +++ b/packages/next/src/routes/rest/index.ts @@ -8,7 +8,7 @@ const handlerBuilder = (config: Promise | SanitizedConfig) => async ( request: Request, - args: { + args?: { params: Promise<{ slug: string[] }> }, ): Promise => { From fb2d92c94d1ed893ad51eb6cf2c6128178c97633 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Wed, 20 Aug 2025 21:34:51 +1000 Subject: [PATCH 14/22] fix(next): args.params guard to prevent runtime errors when handlers are used on static routes. --- packages/next/src/routes/rest/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/routes/rest/index.ts b/packages/next/src/routes/rest/index.ts index e7630994f59..8a01404d4e0 100644 --- a/packages/next/src/routes/rest/index.ts +++ b/packages/next/src/routes/rest/index.ts @@ -30,7 +30,7 @@ const handlerBuilder = initedOGEndpoint = true - const awaitedParams = await args.params + const awaitedParams = args ? await args.params : undefined const response = await handleEndpoints({ config, From 72eeebed5e0bb4876ed5db22663b9e5b115057c7 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:28:02 +1000 Subject: [PATCH 15/22] fix(nextjs): update REST and handlerBuilder params for Next 15.5 compatibility --- packages/next/src/routes/rest/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/next/src/routes/rest/index.ts b/packages/next/src/routes/rest/index.ts index 8a01404d4e0..5fc5c17d0ff 100644 --- a/packages/next/src/routes/rest/index.ts +++ b/packages/next/src/routes/rest/index.ts @@ -9,7 +9,7 @@ const handlerBuilder = async ( request: Request, args?: { - params: Promise<{ slug: string[] }> + params: Promise<{ slug?: string[] }> }, ): Promise => { const awaitedConfig = await config @@ -31,11 +31,12 @@ const handlerBuilder = initedOGEndpoint = true const awaitedParams = args ? await args.params : undefined + const slugArr = awaitedParams?.slug ?? [] const response = await handleEndpoints({ config, - path: awaitedParams - ? `${awaitedConfig.routes.api}/${awaitedParams.slug.join('/')}` + path: slugArr.length + ? `${awaitedConfig.routes.api}/${slugArr.join('/')}` : undefined, request, }) From b97a2ef1c938acb2f19146ef720354f76fc6de26 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:39:06 +1000 Subject: [PATCH 16/22] fix(graphql): add proper type for Next.js route params in POST handler --- packages/next/src/routes/graphql/handler.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/next/src/routes/graphql/handler.ts b/packages/next/src/routes/graphql/handler.ts index 2142997dffc..0e86c396501 100644 --- a/packages/next/src/routes/graphql/handler.ts +++ b/packages/next/src/routes/graphql/handler.ts @@ -96,7 +96,9 @@ export const getGraphql = async (config: Promise | SanitizedCon } export const POST = - (config: Promise | SanitizedConfig) => async (request: Request, params?: any) => { + (config: Promise | SanitizedConfig) => async (request: Request, _params?: Promise<{ slug?: string[] }>) => { + void _params + const originalRequest = request.clone() const req = await createPayloadRequest({ canSetHeaders: true, From 4d10d3de1d2a064804911cbc725ef1a757aa2237 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:44:03 +1000 Subject: [PATCH 17/22] fix(graphql-playground): type params as Next.js route context in GET handler --- packages/next/src/routes/graphql/playground.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/routes/graphql/playground.ts b/packages/next/src/routes/graphql/playground.ts index 5fec2a015db..7b34356b044 100644 --- a/packages/next/src/routes/graphql/playground.ts +++ b/packages/next/src/routes/graphql/playground.ts @@ -1,7 +1,7 @@ import { renderPlaygroundPage } from 'graphql-playground-html' import { createPayloadRequest, type SanitizedConfig } from 'payload' -export const GET = (config: Promise) => async (request: Request, params?: any) => { +export const GET = (config: Promise) => async (request: Request, _params?: Promise<{ slug?: string[] }>) => { const req = await createPayloadRequest({ config, request, From b1372c67695eca259a61135cf1f5c5a762a5d010 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:44:42 +1000 Subject: [PATCH 18/22] fix(graphql): add proper type for Next.js route params in POST handler --- packages/next/src/routes/graphql/handler.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/next/src/routes/graphql/handler.ts b/packages/next/src/routes/graphql/handler.ts index 0e86c396501..f125408afb1 100644 --- a/packages/next/src/routes/graphql/handler.ts +++ b/packages/next/src/routes/graphql/handler.ts @@ -97,8 +97,6 @@ export const getGraphql = async (config: Promise | SanitizedCon export const POST = (config: Promise | SanitizedConfig) => async (request: Request, _params?: Promise<{ slug?: string[] }>) => { - void _params - const originalRequest = request.clone() const req = await createPayloadRequest({ canSetHeaders: true, From 1e44d13a2b16a4c98f449fa4bee60c4dd123d410 Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:48:28 +1000 Subject: [PATCH 19/22] fix(template): update GET handler to use NextRequest for Next.js 15.5 --- .../src/app/(frontend)/next/preview/route.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/templates/with-vercel-website/src/app/(frontend)/next/preview/route.ts b/templates/with-vercel-website/src/app/(frontend)/next/preview/route.ts index 515c79edb68..fb25525b533 100644 --- a/templates/with-vercel-website/src/app/(frontend)/next/preview/route.ts +++ b/templates/with-vercel-website/src/app/(frontend)/next/preview/route.ts @@ -3,18 +3,11 @@ import { getPayload } from 'payload' import { draftMode } from 'next/headers' import { redirect } from 'next/navigation' +import { NextRequest } from "next/server" import configPromise from '@payload-config' -export async function GET( - req: { - cookies: { - get: (name: string) => { - value: string - } - } - } & Request, -): Promise { +export async function GET(req: NextRequest): Promise { const payload = await getPayload({ config: configPromise }) const { searchParams } = new URL(req.url) From 7432cd1bfc801a6bf05734e6ce624f5745a17f7e Mon Sep 17 00:00:00 2001 From: Vincent Vu Date: Thu, 21 Aug 2025 03:50:18 +1000 Subject: [PATCH 20/22] fix(template): update GET handler to use NextRequest for Next.js 15.5 --- .../website/src/app/(frontend)/next/preview/route.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/templates/website/src/app/(frontend)/next/preview/route.ts b/templates/website/src/app/(frontend)/next/preview/route.ts index 515c79edb68..fb25525b533 100644 --- a/templates/website/src/app/(frontend)/next/preview/route.ts +++ b/templates/website/src/app/(frontend)/next/preview/route.ts @@ -3,18 +3,11 @@ import { getPayload } from 'payload' import { draftMode } from 'next/headers' import { redirect } from 'next/navigation' +import { NextRequest } from "next/server" import configPromise from '@payload-config' -export async function GET( - req: { - cookies: { - get: (name: string) => { - value: string - } - } - } & Request, -): Promise { +export async function GET(req: NextRequest): Promise { const payload = await getPayload({ config: configPromise }) const { searchParams } = new URL(req.url) From 0588b61214ea8c8d37239cd498a4a283efb3700e Mon Sep 17 00:00:00 2001 From: Jacob Fletcher Date: Thu, 21 Aug 2025 14:28:28 -0400 Subject: [PATCH 21/22] rm _params and require args --- packages/next/src/routes/graphql/handler.ts | 2 +- packages/next/src/routes/graphql/playground.ts | 2 +- packages/next/src/routes/rest/index.ts | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/next/src/routes/graphql/handler.ts b/packages/next/src/routes/graphql/handler.ts index f125408afb1..c2b55a45f9e 100644 --- a/packages/next/src/routes/graphql/handler.ts +++ b/packages/next/src/routes/graphql/handler.ts @@ -96,7 +96,7 @@ export const getGraphql = async (config: Promise | SanitizedCon } export const POST = - (config: Promise | SanitizedConfig) => async (request: Request, _params?: Promise<{ slug?: string[] }>) => { + (config: Promise | SanitizedConfig) => async (request: Request) => { const originalRequest = request.clone() const req = await createPayloadRequest({ canSetHeaders: true, diff --git a/packages/next/src/routes/graphql/playground.ts b/packages/next/src/routes/graphql/playground.ts index 7b34356b044..f7c7541b682 100644 --- a/packages/next/src/routes/graphql/playground.ts +++ b/packages/next/src/routes/graphql/playground.ts @@ -1,7 +1,7 @@ import { renderPlaygroundPage } from 'graphql-playground-html' import { createPayloadRequest, type SanitizedConfig } from 'payload' -export const GET = (config: Promise) => async (request: Request, _params?: Promise<{ slug?: string[] }>) => { +export const GET = (config: Promise) => async (request: Request) => { const req = await createPayloadRequest({ config, request, diff --git a/packages/next/src/routes/rest/index.ts b/packages/next/src/routes/rest/index.ts index 5fc5c17d0ff..d5fc779203b 100644 --- a/packages/next/src/routes/rest/index.ts +++ b/packages/next/src/routes/rest/index.ts @@ -8,7 +8,7 @@ const handlerBuilder = (config: Promise | SanitizedConfig) => async ( request: Request, - args?: { + args: { params: Promise<{ slug?: string[] }> }, ): Promise => { @@ -35,9 +35,7 @@ const handlerBuilder = const response = await handleEndpoints({ config, - path: slugArr.length - ? `${awaitedConfig.routes.api}/${slugArr.join('/')}` - : undefined, + path: slugArr.length ? `${awaitedConfig.routes.api}/${slugArr.join('/')}` : undefined, request, }) From a172849b4f0f30c954055cd864dd106e4366f483 Mon Sep 17 00:00:00 2001 From: Jacob Fletcher Date: Thu, 21 Aug 2025 15:31:37 -0400 Subject: [PATCH 22/22] revert changes to path formatting --- packages/next/src/routes/rest/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/next/src/routes/rest/index.ts b/packages/next/src/routes/rest/index.ts index d5fc779203b..b3c601dc92b 100644 --- a/packages/next/src/routes/rest/index.ts +++ b/packages/next/src/routes/rest/index.ts @@ -30,12 +30,13 @@ const handlerBuilder = initedOGEndpoint = true - const awaitedParams = args ? await args.params : undefined - const slugArr = awaitedParams?.slug ?? [] + const awaitedParams = await args.params const response = await handleEndpoints({ config, - path: slugArr.length ? `${awaitedConfig.routes.api}/${slugArr.join('/')}` : undefined, + path: awaitedParams + ? `${awaitedConfig.routes.api}/${awaitedParams.slug.join('/')}` + : undefined, request, })