From eb8d5c1c61b7eaa6394d2892112fc947de21a0b4 Mon Sep 17 00:00:00 2001 From: Raymonzut <40148684+Raymonzut@users.noreply.github.com> Date: Sun, 19 Apr 2020 18:00:59 +0200 Subject: [PATCH] Add cors for server --- server/index.js | 3 +++ server/package-lock.json | 14 ++++++++++++++ server/package.json | 1 + 3 files changed, 18 insertions(+) diff --git a/server/index.js b/server/index.js index 67913b0..f67d5d6 100644 --- a/server/index.js +++ b/server/index.js @@ -1,7 +1,10 @@ const express = require('express') +const cors = require('cors') const app = express() +app.use(cors()) + const posts = require('./routes/api/posts') app.use('/api/posts', posts) diff --git a/server/package-lock.json b/server/package-lock.json index 078ef83..1b5c755 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -82,6 +82,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", @@ -283,6 +292,11 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", diff --git a/server/package.json b/server/package.json index 478e3f6..8ccadef 100644 --- a/server/package.json +++ b/server/package.json @@ -11,6 +11,7 @@ "author": "", "license": "ISC", "dependencies": { + "cors": "^2.8.5", "express": "^4.17.1", "mongodb": "^3.5.6" }