fix: nextjs handler x-fal header passthrough

This commit is contained in:
Daniel Rochetti 2023-09-26 21:22:38 -07:00
parent 2e7a4d0a3c
commit a2166cd113
No known key found for this signature in database
GPG Key ID: 791E89AB68BDD5DB
2 changed files with 10 additions and 1 deletions

View File

@ -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",

View File

@ -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',