From a2166cd113927015988912d419298555032396da Mon Sep 17 00:00:00 2001 From: Daniel Rochetti Date: Tue, 26 Sep 2023 21:22:38 -0700 Subject: [PATCH] fix: nextjs handler x-fal header passthrough --- libs/nextjs/package.json | 2 +- libs/nextjs/src/handler.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/nextjs/package.json b/libs/nextjs/package.json index 9e9323b..55ead0b 100644 --- a/libs/nextjs/package.json +++ b/libs/nextjs/package.json @@ -1,7 +1,7 @@ { "name": "@fal-ai/serverless-nextjs", "description": "The fal-serverless Next.js integration", - "version": "0.2.1", + "version": "0.2.2", "license": "MIT", "repository": { "type": "git", diff --git a/libs/nextjs/src/handler.ts b/libs/nextjs/src/handler.ts index 6de92c0..007541f 100644 --- a/libs/nextjs/src/handler.ts +++ b/libs/nextjs/src/handler.ts @@ -71,9 +71,18 @@ export const handler: NextApiHandler = async (request, response) => { return; } + // pass over headers prefixed with x-fal-* + const headers: Record = {}; + Object.keys(request.headers).forEach((key) => { + if (key.toLowerCase().startsWith('x-fal-')) { + headers[key.toLowerCase()] = request.headers[key]; + } + }); + const res = await fetch(targetUrl, { method: request.method, headers: { + ...headers, authorization: `Key ${falKey}`, accept: 'application/json', 'content-type': 'application/json',