From 77cc11ab5f33d9ca65b6f090281571d44b8302a1 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 17 May 2023 11:04:33 +0200 Subject: [PATCH] fix: clientContext isn't available in background functions --- packages/runtime/src/templates/getApiHandler.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/runtime/src/templates/getApiHandler.ts b/packages/runtime/src/templates/getApiHandler.ts index 00321824ee..1e7a2f0b26 100644 --- a/packages/runtime/src/templates/getApiHandler.ts +++ b/packages/runtime/src/templates/getApiHandler.ts @@ -70,9 +70,7 @@ const makeApiHandler = ({ conf, app, pageRoot, NextServer }: MakeApiHandlerParam return bridge } - const { - clientContext: { custom: customContext }, - } = context + const customContext = context.clientContext?.custom // Scheduled functions don't have a URL, but we need to give one so Next knows the route to serve const url = event.rawUrl ? new URL(event.rawUrl) : new URL(path, process.env.URL || 'http://n')