Skip to content

Commit 71d53b9

Browse files
committed
Handle base64 encoded body
1 parent feb09f3 commit 71d53b9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/presets/scaleway/runtime/scaleway-serverless.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import "#nitro/virtual/polyfills";
22
import { useNitroApp } from "nitro/app";
33
import { joinURL, withQuery } from "ufo";
44
import type { serveHandler } from "@scaleway/serverless-functions";
5+
import { Buffer } from "node:buffer";
56

67
const nitroApp = useNitroApp();
78

@@ -24,13 +25,17 @@ export async function handler(event: Event, context: Context) {
2425
event.queryStringParameters ?? {}
2526
);
2627

28+
const body = event.isBase64Encoded
29+
? Buffer.from(event.body, "base64")
30+
: event.body;
31+
2732
const request = new Request(url, {
2833
method: event.httpMethod,
2934
headers,
3035
body:
3136
event.httpMethod === "GET" || event.httpMethod === "HEAD"
3237
? undefined
33-
: event.body,
38+
: body,
3439
});
3540
return nitroApp.fetch(request);
3641
}

0 commit comments

Comments
 (0)