File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -205,5 +205,29 @@ describe('CORS middleware', () => {
205
205
} ) ;
206
206
207
207
208
+ it ( 'should pass through OPTIONS requests if no Origin header was set' , async ( ) => {
209
+
210
+ const options = {
211
+ allowOrigin : [ 'https://example.org' ] ,
212
+ allowHeaders : [ 'Content-Type' , 'Accept' ] ,
213
+ allowMethods : [ 'GET' , 'POST' ] ,
214
+ exposeHeaders : [ 'Link' , 'Date' ]
215
+ } ;
216
+ const headers = { } ;
217
+ const app = new Application ;
218
+ app . use ( cors ( options ) ) ;
219
+
220
+ app . use ( ctx => {
221
+
222
+ ctx . status = 200 ;
223
+ ctx . response . body = ctx . method ;
224
+
225
+ } ) ;
226
+
227
+ const response = await app . subRequest ( 'OPTIONS' , '/' , headers ) ;
228
+ expect ( response . status ) . to . equal ( 200 ) ;
229
+ expect ( response . body ) . to . equal ( 'OPTIONS' ) ;
230
+
231
+ } ) ;
208
232
209
233
} ) ;
You can’t perform that action at this time.
0 commit comments