File tree 2 files changed +7
-2
lines changed 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ import process from 'node:process';
3
3
export const handler = async ( event ) => {
4
4
const targetUrl = process . env . PROXY_TARGET_URL ;
5
5
6
+ const body = event ?. isBase64Encoded ? atob ( event . body ) : event . body ;
7
+
6
8
const response = await fetch ( targetUrl , {
7
9
method : 'POST' ,
8
- body : event . body ,
10
+ body,
9
11
headers : {
10
12
'Content-type' : 'application/x-www-form-urlencoded' ,
11
13
} ,
@@ -29,6 +31,7 @@ export const handler = async (event) => {
29
31
statusCode : response . status ,
30
32
message : response . message ,
31
33
headers : response . headers ,
34
+ targetUrl,
32
35
} ) ;
33
36
34
37
return {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import http from 'http';
2
2
import { handler } from './index.mjs' ;
3
3
import url from 'url' ;
4
4
import process from 'node:process' ;
5
+ import { Buffer } from 'node:buffer' ;
5
6
6
7
const allowedOrigin = process . env . PROXY_ALLOWED_ORIGIN || '*' ;
7
8
@@ -43,7 +44,8 @@ const server = http.createServer(async (req, res) => {
43
44
const lambdaEvent = {
44
45
httpMethod : req . method ,
45
46
queryStringParameters : parsedUrl . query ,
46
- body : body ,
47
+ body : Buffer . from ( body ) . toString ( 'base64' ) ,
48
+ isBase64Encoded : true ,
47
49
} ;
48
50
49
51
// Call the handler (same code used in AWS Lambda)
You can’t perform that action at this time.
0 commit comments