Add CORS Module

pull/1/head
Florian Hartwich 2017-05-16 12:55:53 +02:00
parent 2537dcff07
commit fdb7105e1b
2 changed files with 10 additions and 1 deletions

View File

@ -15,6 +15,7 @@
"async": "^2.4.0",
"bcryptjs": "^2.4.3",
"body-parser": "~1.13.2",
"cors": "^2.8.3",
"cron": "^1.2.1",
"debug": "~2.2.0",
"express": "~4.13.1",

View File

@ -6,6 +6,7 @@ const favicon = require('serve-favicon');
const bodyParser = require('body-parser');
const requestLogger = require('morgan');
const debug = require('debug')('cc:server');
const cors = require('cors')
const mongoose = require('mongoose');
// own modules
@ -34,7 +35,15 @@ mongoose.Promise = global.Promise;
// app creation
const app = express();
// setup CORS-middleware
const corsOptions = {
methods: ['GET'],
optionsSuccessStatus: 200
};
app.use(cors(corsOptions));
// Middlewares *************************************************
app.use(favicon(path.join(__dirname + '/..', 'public', 'favicon.ico')));
app.use(express.static(path.join(__dirname + '/..', 'public')));
app.use(bodyParser.json());
@ -52,7 +61,6 @@ app.use(restAPIchecks);
app.use(urls.auth, authenticateRouter);
app.use(urls.signatures, signatureRouter);
// all following routes need a jwt token to access
app.use(urls.overview, overviewRouter);
app.use(urls.users, userRouter);
app.use(urls.squads, squadRouter);