Added CORS

pull/2/head
Trivernis 5 years ago
parent acfea36665
commit b671845337

@ -8,5 +8,4 @@ RUN npm rebuild node-sass
RUN gulp
COPY . .
EXPOSE 8080
EXPOSE 5432
CMD ["npm" , "run"]

18
package-lock.json generated

@ -93,6 +93,15 @@
"@types/express": "*"
}
},
"@types/cors": {
"version": "2.8.6",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.6.tgz",
"integrity": "sha512-invOmosX0DqbpA+cE2yoHGUlF/blyf7nB0OGYBBiH27crcVm5NmFaZkLP4Ta1hGaesckCi5lVLlydNJCxkTOSg==",
"dev": true,
"requires": {
"@types/express": "*"
}
},
"@types/express": {
"version": "4.17.1",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.1.tgz",
@ -1540,6 +1549,15 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"requires": {
"object-assign": "^4",
"vary": "^1"
}
},
"crc": {
"version": "3.8.0",
"resolved": "https://registry.npmjs.org/crc/-/crc-3.8.0.tgz",

@ -23,6 +23,7 @@
"@types/compression": "^1.0.1",
"@types/connect-pg-simple": "^4.2.0",
"@types/cookie-parser": "^1.4.2",
"@types/cors": "^2.8.6",
"@types/express": "^4.17.1",
"@types/express-graphql": "^0.8.0",
"@types/express-session": "^1.15.14",
@ -50,6 +51,7 @@
"compression": "^1.7.4",
"connect-pg-simple": "^6.0.1",
"cookie-parser": "^1.4.4",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-graphql": "^0.9.0",
"express-session": "^1.16.2",

@ -1,6 +1,7 @@
import * as compression from "compression";
import connectPgSimple = require("connect-pg-simple");
import * as cookieParser from "cookie-parser";
import * as cors from "cors";
import * as express from "express";
import * as graphqlHTTP from "express-graphql";
import * as session from "express-session";
@ -63,6 +64,9 @@ class App {
this.app.use(express.static(path.join(__dirname, "public")));
this.app.use(cookieParser());
this.app.use(appSession);
if (globals.config.server.cors) {
this.app.use(cors());
}
this.app.use((req, res, next) => {
logger.verbose(`${req.method} ${req.url}`);
next();

@ -9,6 +9,7 @@ database:
# http server configuration
server:
port: 8080
cors: false
session:
secret: REPLACE WITH SAFE RANDOM GENERATED SECRET

Loading…
Cancel
Save