From aab2e20e03647bc011ebb44fee5df556a2c7c608 Mon Sep 17 00:00:00 2001 From: Haris Razis Date: Fri, 25 Dec 2020 09:44:56 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Change=20cors=20to=20only=20acce?= =?UTF-8?q?pt=20localhost:8080?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/server/index.js b/server/index.js index 5fe5445..a710039 100644 --- a/server/index.js +++ b/server/index.js @@ -13,8 +13,12 @@ const authRoute = require('./routes/auth') const passport = require('./services/passport'); const {session_secret} = require('./config/keys'); -//allow all requests for development. -app.use(cors()) +app.use(cors( + { + origin: ['http://localhost:8080'], + credentials: true + } +)); app.use(bodyParser.urlencoded({ extended: true @@ -34,6 +38,4 @@ app.use(dataRoute) app.use(authRoute) const PORT = process.env.PORT || 8000; -server.listen(PORT, () => { - console.log(chalk.green.bold(`Server listening on port ${PORT}!`)); -}); +server.listen(PORT, () => console.log(chalk.green.bold(`Server listening on port ${PORT}!`)));