Commit 6a12eff2 authored by Juha's avatar Juha

Cors setup

parent 02c9758c
const restify = require('restify');
const helmet = require('helmet');
const corsMiddleware = require('restify-cors-middleware');
const nconf = require('nconf');
require('./lib/config')();
const cors = corsMiddleware({
preflightMaxAge: 5,
origins: nconf.get('http:allowedOrigins').split(','),
});
const app = restify.createServer({ name: 'Auth Service' });
app.use(helmet({
referrerPolicy: {
policy: 'same-origin',
},
}));
app.pre(cors.preflight);
app.use(cors.actual);
app.use(restify.plugins.acceptParser(app.acceptable));
app.use(restify.plugins.bodyParser({ mapParams: true }));
......
const requiredValues = [
'NODE_ENV',
'http:port',
'http:allowedOrigins',
'jwt:accessToken:secret',
'jwt:accessToken:expiration',
'jwt:accessToken:audience',
......
......@@ -7011,6 +7011,14 @@
}
}
},
"restify-cors-middleware": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/restify-cors-middleware/-/restify-cors-middleware-1.1.1.tgz",
"integrity": "sha1-BmiFAvoIuMYngxA4RMh9z8MNzz4=",
"requires": {
"assert-plus": "1.0.0"
}
},
"restify-errors": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/restify-errors/-/restify-errors-6.0.0.tgz",
......
......@@ -29,6 +29,7 @@
"pg": "^7.4.3",
"pg-hstore": "^2.3.2",
"restify": "^7.2.0",
"restify-cors-middleware": "^1.1.1",
"restify-errors": "^6.0.0",
"restify-jwt-community": "^1.0.5",
"sequelize": "^4.37.8",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment