@@ -57,7 +57,7 @@ export const config = {
5757 ) ,
5858 schema . boolean ( { defaultValue : false } )
5959 ) ,
60- customResponseHeaders : schema . recordOf ( schema . string ( ) , schema . string ( ) , {
60+ customResponseHeaders : schema . recordOf ( schema . string ( ) , schema . any ( ) , {
6161 defaultValue : { } ,
6262 } ) ,
6363 host : schema . string ( {
@@ -136,7 +136,7 @@ export class HttpConfig {
136136 public socketTimeout : number ;
137137 public port : number ;
138138 public cors : boolean | { origin : string [ ] } ;
139- public customResponseHeaders : Record < string , string > ;
139+ public customResponseHeaders : Record < string , string | string [ ] > ;
140140 public maxPayload : ByteSizeValue ;
141141 public basePath ?: string ;
142142 public rewriteBasePath : boolean ;
@@ -153,7 +153,15 @@ export class HttpConfig {
153153 this . host = rawHttpConfig . host ;
154154 this . port = rawHttpConfig . port ;
155155 this . cors = rawHttpConfig . cors ;
156- this . customResponseHeaders = rawHttpConfig . customResponseHeaders ;
156+ this . customResponseHeaders = Object . entries ( rawHttpConfig . customResponseHeaders ?? { } ) . reduce (
157+ ( headers , [ key , value ] ) => {
158+ return {
159+ ...headers ,
160+ [ key ] : Array . isArray ( value ) ? value . map ( e => convertHeader ( e ) ) : convertHeader ( value ) ,
161+ } ;
162+ } ,
163+ { }
164+ ) ;
157165 this . maxPayload = rawHttpConfig . maxPayload ;
158166 this . name = rawHttpConfig . name ;
159167 this . basePath = rawHttpConfig . basePath ;
@@ -166,3 +174,7 @@ export class HttpConfig {
166174 this . xsrf = rawHttpConfig . xsrf ;
167175 }
168176}
177+
178+ const convertHeader = ( entry : any ) : string => {
179+ return typeof entry === 'object' ? JSON . stringify ( entry ) : String ( entry ) ;
180+ } ;
0 commit comments