File tree Expand file tree Collapse file tree 4 files changed +16
-13
lines changed Expand file tree Collapse file tree 4 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -208,17 +208,20 @@ export const cors =
208
208
if ( origins . length ) {
209
209
const from = request . headers . get ( 'Origin' ) ?? ''
210
210
for ( let i = 0 ; i < origins . length ; i ++ ) {
211
- const value = processOrigin ( origins [ i ] , request , from )
212
- if ( value === true ) {
213
- set . headers [ 'Vary' ] = origin ? 'Origin' : '*'
214
- set . headers [ 'Access-Control-Allow-Origin' ] =
215
- request . headers . get ( 'Origin' ) ?? '*'
216
-
217
- return
211
+ const currentOrigin = origins [ i ] ;
212
+ if ( currentOrigin ) {
213
+ const value = processOrigin ( currentOrigin , request , from )
214
+ if ( value === true ) {
215
+ set . headers [ 'Vary' ] = origin ? 'Origin' : '*'
216
+ set . headers [ 'Access-Control-Allow-Origin' ] =
217
+ request . headers . get ( 'Origin' ) ?? '*'
218
+
219
+ return
220
+ }
221
+
222
+ // value can be string (truthy value) but not `true`
223
+ if ( value ) headers . push ( value )
218
224
}
219
-
220
- // value can be string (truthy value) but not `true`
221
- if ( value ) headers . push ( value )
222
225
}
223
226
}
224
227
Original file line number Diff line number Diff line change 90
90
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
91
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
92
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
93
+ "noUncheckedIndexedAccess" : true , /* Add 'undefined' to a type when accessed using an index. */
94
94
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
95
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
96
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
Original file line number Diff line number Diff line change 90
90
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
91
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
92
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
93
+ "noUncheckedIndexedAccess" : true , /* Add 'undefined' to a type when accessed using an index. */
94
94
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
95
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
96
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
Original file line number Diff line number Diff line change 90
90
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
91
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
92
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
93
+ "noUncheckedIndexedAccess" : true , /* Add 'undefined' to a type when accessed using an index. */
94
94
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
95
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
96
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
You can’t perform that action at this time.
0 commit comments