@@ -100,11 +100,20 @@ function HttpServer(options) {
100100
101101 if ( options . cors ) {
102102 this . headers [ 'Access-Control-Allow-Origin' ] = '*' ;
103- this . headers [ 'Access-Control-Allow-Headers' ] = 'Origin, X-Requested-With, Content-Type, Accept, Range' ;
103+ // Default allowed headers to CORS-safelisted request headers:
104+ // https://fetch.spec.whatwg.org/#cors-safelisted-request-header
105+ this . headers [ 'Access-Control-Allow-Headers' ] = 'Accept, Accept-Language, Content-Language, Content-Type' ;
106+ // Default exposed headers to CORS-safelisted response headers:
107+ // https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name
108+ this . headers [ 'Access-Control-Expose-Headers' ] = 'Cache-Control, Content-Language, Content-Length, Content-Type, Expires, Last-Modified, Pragma' ;
104109 if ( options . corsHeaders ) {
105110 options . corsHeaders . split ( / \s * , \s * / )
106- . forEach ( function ( h ) { this . headers [ 'Access-Control-Allow-Headers' ] += ', ' + h ; } , this ) ;
111+ . forEach ( function ( h ) {
112+ this . headers [ 'Access-Control-Allow-Headers' ] += ', ' + h ;
113+ this . headers [ 'Access-Control-Expose-Headers' ] += ', ' + h ;
114+ } , this ) ;
107115 }
116+ console . log ( 'headers' , this . headers ) ;
108117 before . push ( corser . create ( options . corsHeaders ? {
109118 requestHeaders : this . headers [ 'Access-Control-Allow-Headers' ] . split ( / \s * , \s * / )
110119 } : null ) ) ;
0 commit comments