diff options
| -rw-r--r-- | server.js | 20 |
1 files changed, 4 insertions, 16 deletions
@@ -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 ( |
