Skip to content

Commit 208b86c

Browse files
committedOct 8, 2022
Revert "fix: Calling all options even if origin header is not present (#87)"
This reverts commit 2e8da5b.
1 parent d5456f7 commit 208b86c

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed
 

‎index.js

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ module.exports = function(options) {
5858
// https://github.com/rs/cors/issues/10
5959
ctx.vary('Origin');
6060

61+
if (!requestOrigin) return await next();
62+
6163
let origin;
6264
if (typeof options.origin === 'function') {
6365
origin = await options.origin(ctx);

‎test/cors.test.js

-8
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,6 @@ describe('cors.test.js', function() {
7777
.expect({ foo: 'bar' })
7878
.expect(200, done);
7979
});
80-
81-
it('should always set `Access-Control-Allow-Origin` to *, even if no Origin is passed on request', function(done) {
82-
request(app.listen())
83-
.get('/')
84-
.expect('Access-Control-Allow-Origin', '*')
85-
.expect({ foo: 'bar' })
86-
.expect(200, done);
87-
});
8880
});
8981

9082
describe('options.secureContext=true', function() {

0 commit comments

Comments
 (0)
Please sign in to comment.