File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -166,22 +166,23 @@ describe('SettingService', () => {
166
166
} ) ;
167
167
expect ( result ) . toEqual (
168
168
new Set ( [
169
+ '*' ,
169
170
'https://example.com' ,
170
171
'https://test.com' ,
171
172
'https://another.com' ,
172
173
] ) ,
173
174
) ;
174
175
} ) ;
175
176
176
- it ( 'should return an empty set if no settings are found' , async ( ) => {
177
+ it ( 'should return the config allowed cors only if no settings are found' , async ( ) => {
177
178
jest . spyOn ( settingService , 'find' ) . mockResolvedValue ( [ ] ) ;
178
179
179
180
const result = await settingService . getAllowedOrigins ( ) ;
180
181
181
182
expect ( settingService . find ) . toHaveBeenCalledWith ( {
182
183
label : 'allowed_domains' ,
183
184
} ) ;
184
- expect ( result ) . toEqual ( new Set ( ) ) ;
185
+ expect ( result ) . toEqual ( new Set ( [ '*' ] ) ) ;
185
186
} ) ;
186
187
187
188
it ( 'should handle settings with empty values' , async ( ) => {
@@ -197,7 +198,7 @@ describe('SettingService', () => {
197
198
expect ( settingService . find ) . toHaveBeenCalledWith ( {
198
199
label : 'allowed_domains' ,
199
200
} ) ;
200
- expect ( result ) . toEqual ( new Set ( [ 'https://example.com' ] ) ) ;
201
+ expect ( result ) . toEqual ( new Set ( [ '*' , ' https://example.com'] ) ) ;
201
202
} ) ;
202
203
} ) ;
203
204
} ) ;
Original file line number Diff line number Diff line change @@ -142,12 +142,16 @@ export class SettingService extends BaseService<Setting> {
142
142
label : 'allowed_domains' ,
143
143
} ) ) as TextSetting [ ] ;
144
144
145
- const uniqueOrigins = new Set (
146
- settings . flatMap ( ( setting ) =>
147
- setting . value . split ( ',' ) . filter ( ( o ) => ! ! o ) ,
148
- ) ,
145
+ const allowedDomains = settings . flatMap ( ( setting ) =>
146
+ setting . value . split ( ',' ) . filter ( ( o ) => ! ! o ) ,
149
147
) ;
150
148
149
+ const uniqueOrigins = new Set ( [
150
+ ...config . security . cors . allowOrigins ,
151
+ ...config . sockets . onlyAllowOrigins ,
152
+ ...allowedDomains ,
153
+ ] ) ;
154
+
151
155
return uniqueOrigins ;
152
156
}
153
157
You can’t perform that action at this time.
0 commit comments