Merge pull request #928 from CartoDB/extract-cors-mw

Make cors middleware more generic and link it just to application level
This commit is contained in:
Daniel G. Aubert
2018-04-10 18:29:59 +02:00
committed by GitHub
3 changed files with 12 additions and 10 deletions
+2 -3
View File
@@ -1,5 +1,4 @@
const { templateName } = require('../../backends/template_maps');
const cors = require('../../middleware/cors');
const credentials = require('../../middleware/credentials');
const rateLimit = require('../../middleware/rate-limit');
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit;
@@ -20,6 +19,8 @@ function AdminTemplateController(authApi, templateMaps, userLimitsApi) {
module.exports = AdminTemplateController;
AdminTemplateController.prototype.register = function (templateRouter) {
templateRouter.options(`/:template_id`);
templateRouter.post(
`/`,
credentials(),
@@ -66,8 +67,6 @@ AdminTemplateController.prototype.register = function (templateRouter) {
listTemplates({ templateMaps: this.templateMaps }),
sendResponse()
);
templateRouter.options(`/:template_id`, cors('Content-Type'));
};
function checkContentType ({ action, label }) {