diff options
| author | Bobby <[email protected]> | 2022-03-21 01:35:54 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-03-21 01:35:54 -0400 |
| commit | 19b1b5d6e5ae9bf8e878858cf8a5385cd463142b (patch) | |
| tree | 4b89b1e019d1dc220d1f70d8e57474bba76a1d31 | |
| parent | d760ad4ae6d33daf121b1a310fd10764afc326c8 (diff) | |
| download | luciferreeves.github.io-19b1b5d6e5ae9bf8e878858cf8a5385cd463142b.tar.xz luciferreeves.github.io-19b1b5d6e5ae9bf8e878858cf8a5385cd463142b.zip | |
Remove CORS
| -rw-r--r-- | server.js | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -9,6 +9,25 @@ 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 + next(); +}); +app.use(function (req, res, next) { if ( req.get("X-Forwarded-Proto") === "http" && !["localhost", "127.0.0.1"].includes( @@ -37,7 +56,6 @@ app.set("view engine", "html"); app.set("views", __dirname + "/public/views"); app.use(routes); - // Start the server app.listen(port, () => { console.log(`Server is running on port ${port}`); |
