File tree Expand file tree Collapse file tree 2 files changed +2
-37
lines changed Expand file tree Collapse file tree 2 files changed +2
-37
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { promises as fs } from 'fs'
3
3
import type { IncomingHttpHeaders } from 'http'
4
4
import path from 'path'
5
5
6
+ import { shouldBase64Encode } from '@netlify/dev-utils'
6
7
import express , { type Request , type RequestHandler } from 'express'
7
8
import expressLogging from 'express-logging'
8
9
import { jwtDecode } from 'jwt-decode'
@@ -29,7 +30,6 @@ import { createFormSubmissionHandler } from './form-submissions-handler.js'
29
30
import { FunctionsRegistry } from './registry.js'
30
31
import { handleScheduledFunction } from './scheduled.js'
31
32
import { handleSynchronousFunction } from './synchronous.js'
32
- import { shouldBase64Encode } from './utils.js'
33
33
34
34
type FunctionsSettings = Pick < ServerSettings , 'functions' | 'functionsPort' >
35
35
@@ -122,7 +122,7 @@ export const createHandler = function (options: GetFunctionsServerOptions): Requ
122
122
return
123
123
}
124
124
125
- const isBase64Encoded = shouldBase64Encode ( request . header ( 'content-type' ) )
125
+ const isBase64Encoded = shouldBase64Encode ( request . header ( 'content-type' ) ?? '' )
126
126
let body
127
127
if ( hasBody ( request ) ) {
128
128
body = request . body . toString ( isBase64Encoded ? 'base64' : 'utf8' )
Original file line number Diff line number Diff line change @@ -20,39 +20,4 @@ export const formatLambdaError = (err: Error | InvocationError): string =>
20
20
`${ 'errorType' in err ? err . errorType : 'Error' } : ${ 'errorMessage' in err ? err . errorMessage : err . message } ` ,
21
21
)
22
22
23
- // should be equivalent to https://github.com/netlify/proxy/blob/main/pkg/functions/request.go#L105
24
- const exceptionsList = new Set ( [
25
- 'application/csp-report' ,
26
- 'application/graphql' ,
27
- 'application/json' ,
28
- 'application/javascript' ,
29
- 'application/x-www-form-urlencoded' ,
30
- 'application/x-ndjson' ,
31
- 'application/xml' ,
32
- ] )
33
-
34
- export const shouldBase64Encode = function ( contentType ?: string ) : boolean {
35
- if ( ! contentType ) {
36
- return true
37
- }
38
-
39
- const [ contentTypeSegment ] = contentType . split ( ';' )
40
- contentType = contentTypeSegment
41
- contentType = contentType . toLowerCase ( )
42
-
43
- if ( contentType . startsWith ( 'text/' ) ) {
44
- return false
45
- }
46
-
47
- if ( contentType . endsWith ( '+json' ) || contentType . endsWith ( '+xml' ) ) {
48
- return false
49
- }
50
-
51
- if ( exceptionsList . has ( contentType ) ) {
52
- return false
53
- }
54
-
55
- return true
56
- }
57
-
58
23
export const styleFunctionName = ( name : string ) : string => chalk . magenta ( name )
You can’t perform that action at this time.
0 commit comments