Ivan Greenking 1 year ago
parent
commit
267154deb9
3 changed files with 11 additions and 0 deletions
  1. 1 0
      index.js
  2. 9 0
      package-lock.json
  3. 1 0
      package.json

+ 1 - 0
index.js

@@ -157,6 +157,7 @@ const upload  = require('multer')({ dest: uploadPath })
     console.log(printSchema(schema))
 
     const app = express();
+    app.use(require('cors')())
     app.use(express.static('public'));
     app.use('/graphql', express_graphql(jwtGQL({anonSchema, anonResolvers, schema, createContext: getModels, graphiql: true, secret: jwtSecret})))
 

+ 9 - 0
package-lock.json

@@ -175,6 +175,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"
+      }
+    },
     "debug": {
       "version": "2.6.9",
       "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",

+ 1 - 0
package.json

@@ -21,6 +21,7 @@
   "author": "Ivan Grynkin",
   "license": "MIT",
   "dependencies": {
+    "cors": "^2.8.5",
     "express": "^4.17.1",
     "express-graphql": "^0.9.0",
     "graphql": "^14.4.2",