Skip to content

Commit

Permalink
adding options to the supported request types (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonwinton authored Feb 14, 2018
1 parent 19cea31 commit fd355d5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ function compileTemplate(filename) {
*/
function protectRoutes(site) {
return function (req, res, next) {
if (module.exports.isProtectedRoute(req)) { // allow mocking of these for testing
if (req.method !== 'OPTIONS' && module.exports.isProtectedRoute(req)) { // allow mocking of these for testing
module.exports.isAuthenticated(site)(req, res, next);
} else {
next();
Expand Down
2 changes: 1 addition & 1 deletion lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const _ = require('lodash'),
plugins = require('./plugins'),
cors = {
origins: '*',
methods: ['GET', 'POST', 'PUT', 'DELETE'].join(','),
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'].join(','),
headers: ['Accept', 'Accept-Encoding', 'Authorization', 'Content-Type', 'Host', 'Referer', 'Origin', 'User-Agent',
'X-Forwarded-For', 'X-Forwarded-Host', 'X-Forwarded-Proto'].join(',')
};
Expand Down
2 changes: 1 addition & 1 deletion lib/routes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe(_.startCase(filename), function () {

test({method: 'OPTIONS', headers: {}}, res);

sinon.assert.calledWith(spy, 'Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE');
sinon.assert.calledWith(spy, 'Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE,OPTIONS');
sinon.assert.calledWith(spy, 'Access-Control-Allow-Headers', sinon.match.string);
});
});
Expand Down

0 comments on commit fd355d5

Please sign in to comment.