fix: nextjs handler x-fal header passthrough
This commit is contained in:
parent
2e7a4d0a3c
commit
a2166cd113
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@fal-ai/serverless-nextjs",
|
"name": "@fal-ai/serverless-nextjs",
|
||||||
"description": "The fal-serverless Next.js integration",
|
"description": "The fal-serverless Next.js integration",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@ -71,9 +71,18 @@ export const handler: NextApiHandler = async (request, response) => {
|
|||||||
return;
|
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, {
|
const res = await fetch(targetUrl, {
|
||||||
method: request.method,
|
method: request.method,
|
||||||
headers: {
|
headers: {
|
||||||
|
...headers,
|
||||||
authorization: `Key ${falKey}`,
|
authorization: `Key ${falKey}`,
|
||||||
accept: 'application/json',
|
accept: 'application/json',
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user