File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
packages/adapter-node/src Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @sveltejs/adapter-node ' : patch
3
+ ---
4
+
5
+ fix: fallback to ` host ` header if header specified by ` HOST_HEADER ` is not in request headers
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const origin = env('ORIGIN', undefined);
19
19
const xff_depth = parseInt ( env ( 'XFF_DEPTH' , '1' ) ) ;
20
20
const address_header = env ( 'ADDRESS_HEADER' , '' ) . toLowerCase ( ) ;
21
21
const protocol_header = env ( 'PROTOCOL_HEADER' , '' ) . toLowerCase ( ) ;
22
- const host_header = env ( 'HOST_HEADER' , 'host ' ) . toLowerCase ( ) ;
22
+ const host_header = env ( 'HOST_HEADER' , '' ) . toLowerCase ( ) ;
23
23
const port_header = env ( 'PORT_HEADER' , '' ) . toLowerCase ( ) ;
24
24
25
25
const body_size_limit = parse_as_bytes ( env ( 'BODY_SIZE_LIMIT' , '512K' ) ) ;
@@ -182,14 +182,11 @@ function sequence(handlers) {
182
182
* @returns
183
183
*/
184
184
function get_origin ( headers ) {
185
- const protocol = ( protocol_header && headers [ protocol_header ] ) || 'https' ;
186
- const host = headers [ host_header ] ;
185
+ const protocol = ( protocol_header && headers [ protocol_header ] ) ?? 'https' ;
186
+ const host = ( host_header && headers [ host_header ] ) ?? headers [ 'host' ] ;
187
187
const port = port_header && headers [ port_header ] ;
188
- if ( port ) {
189
- return `${ protocol } ://${ host } :${ port } ` ;
190
- } else {
191
- return `${ protocol } ://${ host } ` ;
192
- }
188
+
189
+ return port ? `${ protocol } ://${ host } :${ port } ` : `${ protocol } ://${ host } ` ;
193
190
}
194
191
195
192
export const handler = sequence (
You can’t perform that action at this time.
0 commit comments