diff options
author | Mateja <mail@matejamaric.com> | 2021-07-11 18:12:37 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2021-07-11 18:12:37 +0200 |
commit | 7368c45fe400f407b55972be34f240c98759e9ae (patch) | |
tree | 418bef9f88a810ddd61327f4db49a80d20085e8a /server | |
parent | 6da47e69d282921b45b9ed36940892e229846469 (diff) | |
download | mevn-ecommerce-7368c45fe400f407b55972be34f240c98759e9ae.tar.gz mevn-ecommerce-7368c45fe400f407b55972be34f240c98759e9ae.zip |
Add CORS support.
Diffstat (limited to 'server')
-rw-r--r-- | server/main.js | 3 | ||||
-rw-r--r-- | server/package-lock.json | 9 | ||||
-rw-r--r-- | server/package.json | 1 |
3 files changed, 13 insertions, 0 deletions
diff --git a/server/main.js b/server/main.js index e6f5558..ab7ce4d 100644 --- a/server/main.js +++ b/server/main.js @@ -2,6 +2,7 @@ const express = require('express'); const app = express(); const mongoose = require('mongoose'); const passport = require('passport'); +const cors = require('cors'); const {port, mongoUrl} = require("./config/env"); const apiRoutes = require('./routes/api'); @@ -20,6 +21,8 @@ app.use(express.json()); require('./config/passport'); app.use(passport.initialize()); +app.use(cors()); + app.use('/api', apiRoutes); app.use('/api/uploads', express.static('uploads')); diff --git a/server/package-lock.json b/server/package-lock.json index 20078c9..e71a274 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -424,6 +424,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" + } + }, "crypto-random-string": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", diff --git a/server/package.json b/server/package.json index a1c3c05..9209187 100644 --- a/server/package.json +++ b/server/package.json @@ -11,6 +11,7 @@ "license": "GPL-3.0", "dependencies": { "bcryptjs": "^2.4.3", + "cors": "^2.8.5", "dotenv": "^10.0.0", "express": "^4.17.1", "jsonwebtoken": "^8.5.1", |