diff --git a/package-lock.json b/package-lock.json index 829a686..838e8c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2996,6 +2996,11 @@ } } }, + "express-cors": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/express-cors/-/express-cors-0.0.3.tgz", + "integrity": "sha1-XCWnjXvmmk/LCEEssnyN/HWIlr0=" + }, "ext": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz", diff --git a/package.json b/package.json index 5414519..f214c48 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "crc": "^3.8.0", "dotenv": "^8.2.0", "express": "^4.17.1", + "express-cors": "0.0.3", "graphql": "^15.3.0", "messagepack": "^1.1.12", "pg": "^8.3.3", diff --git a/src/index.ts b/src/index.ts index 2811f2d..99eafdd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,7 +36,7 @@ import workshopResolvers from './resolvers/workshopResolvers'; import { ActionLog } from './model/ActionLog'; import actionLogResolvers from './resolvers/actionLogResolvers'; import { ActionLogAPI } from './datasources/db/actionLogAPI'; - +const cors = require('express-cors'); require('dotenv').config(); const connOptions: ConnectionOptions = { @@ -135,7 +135,11 @@ const app = express(); app.post('/graphql', authenticate); app.get(/\/graphql?&.*query=/, authenticate); server.applyMiddleware({ app }); - +app.use(cors({ + allowedOrigins: [ + '*' + ] +})); app.listen(4000, async () => { await userAPI.createDefinedPermissions().catch( err => console.log(err));