Skip to content

Commit

Permalink
Revert "fix: Calling all options even if origin header is not present (
Browse files Browse the repository at this point in the history
…#87)"

This reverts commit 2e8da5b.
  • Loading branch information
fengmk2 committed Oct 8, 2022
1 parent d5456f7 commit 208b86c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ module.exports = function(options) {
// https://github.com/rs/cors/issues/10
ctx.vary('Origin');

if (!requestOrigin) return await next();

let origin;
if (typeof options.origin === 'function') {
origin = await options.origin(ctx);
Expand Down
8 changes: 0 additions & 8 deletions test/cors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ describe('cors.test.js', function() {
.expect({ foo: 'bar' })
.expect(200, done);
});

it('should always set `Access-Control-Allow-Origin` to *, even if no Origin is passed on request', function(done) {
request(app.listen())
.get('/')
.expect('Access-Control-Allow-Origin', '*')
.expect({ foo: 'bar' })
.expect(200, done);
});
});

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

0 comments on commit 208b86c

Please sign in to comment.