diff --git a/package.json b/package.json index 965973ac..e9aa5d25 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "babel-register": "^6.14.0", "body-parser": "^1.15.2", "bunyan": "^1.8.1", + "cors": "^2.8.4", "express": "^4.14.0", "fs-extra": "^5.0.0", "joi": "^13.1.2", diff --git a/src/elastalert_server.js b/src/elastalert_server.js index d3747b45..8db07e9d 100644 --- a/src/elastalert_server.js +++ b/src/elastalert_server.js @@ -9,6 +9,7 @@ import ProcessController from './controllers/process'; import RulesController from './controllers/rules'; import TemplatesController from './controllers/templates'; import TestController from './controllers/test'; +import cors from 'cors'; let logger = new Logger('Server'); @@ -58,6 +59,7 @@ export default class ElastalertServer { // Start the server when the config is loaded config.ready(function () { try { + self._express.use(cors()); self._express.use(bodyParser.json()); self._express.use(bodyParser.urlencoded({ extended: true })); self._setupRouter();