Skip to content

Commit

Permalink
fix: nextjs handler x-fal header passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
drochetti committed Sep 27, 2023
1 parent 2e7a4d0 commit a2166cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 9 additions & 0 deletions libs/nextjs/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,18 @@ export const handler: NextApiHandler = async (request, response) => {
return;
}

// pass over headers prefixed with x-fal-*
const headers: Record<string, string | string[] | undefined> = {};
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',
Expand Down

0 comments on commit a2166cd

Please sign in to comment.