aboutsummaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-03-21 01:35:54 -0400
committerBobby <[email protected]>2022-03-21 01:35:54 -0400
commit19b1b5d6e5ae9bf8e878858cf8a5385cd463142b (patch)
tree4b89b1e019d1dc220d1f70d8e57474bba76a1d31 /server.js
parentd760ad4ae6d33daf121b1a310fd10764afc326c8 (diff)
downloadluciferreeves.github.io-19b1b5d6e5ae9bf8e878858cf8a5385cd463142b.tar.xz
luciferreeves.github.io-19b1b5d6e5ae9bf8e878858cf8a5385cd463142b.zip
Remove CORS
Diffstat (limited to 'server.js')
-rw-r--r--server.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/server.js b/server.js
index 4568b21..cc428d0 100644
--- a/server.js
+++ b/server.js
@@ -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}`);