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'
33import type { IncomingHttpHeaders } from 'http'
44import path from 'path'
55
6+ import { shouldBase64Encode } from '@netlify/dev-utils'
67import express , { type Request , type RequestHandler } from 'express'
78import expressLogging from 'express-logging'
89import { jwtDecode } from 'jwt-decode'
@@ -29,7 +30,6 @@ import { createFormSubmissionHandler } from './form-submissions-handler.js'
2930import { FunctionsRegistry } from './registry.js'
3031import { handleScheduledFunction } from './scheduled.js'
3132import { handleSynchronousFunction } from './synchronous.js'
32- import { shouldBase64Encode } from './utils.js'
3333
3434type FunctionsSettings = Pick < ServerSettings , 'functions' | 'functionsPort' >
3535
@@ -122,7 +122,7 @@ export const createHandler = function (options: GetFunctionsServerOptions): Requ
122122 return
123123 }
124124
125- const isBase64Encoded = shouldBase64Encode ( request . header ( 'content-type' ) )
125+ const isBase64Encoded = shouldBase64Encode ( request . header ( 'content-type' ) ?? '' )
126126 let body
127127 if ( hasBody ( request ) ) {
128128 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 =>
2020 `${ 'errorType' in err ? err . errorType : 'Error' } : ${ 'errorMessage' in err ? err . errorMessage : err . message } ` ,
2121 )
2222
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-
5823export const styleFunctionName = ( name : string ) : string => chalk . magenta ( name )
You can’t perform that action at this time.
0 commit comments