From 865fbbd889e7712faf8f0524ca8ca6a50c2aa0ee Mon Sep 17 00:00:00 2001 From: Bobby Date: Mon, 21 Mar 2022 01:42:23 -0400 Subject: Remove CORS module --- server.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'server.js') diff --git a/server.js b/server.js index 49d8579..c64bf8c 100644 --- a/server.js +++ b/server.js @@ -8,23 +8,11 @@ const routes = require("./routes"); // Create the server const app = express(); app.use(function (req, res, next) { - // Website you wish to allow to connect - res.setHeader("Access-Control-Allow-Origin", "http://localhost:3000", "https://thatcomputerscientist.com"); - - // Request methods you wish to allow - res.setHeader( - "Access-Control-Allow-Methods", - "GET, POST, OPTIONS, PUT, PATCH, DELETE" - ); - - // Request headers you wish to allow - res.setHeader( - "Access-Control-Allow-Headers", - "X-Requested-With,content-type" - ); - - // Pass to next layer of middleware + // Only allow http://localhost:3000 and https://thatcomputerscientist.com to access the API + res.header("Access-Control-Allow-Origin", "http://localhost:3000"); + res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); next(); + }); app.use(function (req, res, next) { if ( -- cgit v1.2.3