aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-06-26 21:13:59 +0530
committerBobby <[email protected]>2022-06-26 21:13:59 +0530
commit5cc36e5144e6e3bba259a837fa06321c547f49d8 (patch)
treed1247370b4c5ba154b6763b1744a3a0a330d0db8
parent643787b0eeab39be718ae5d781781d3cc07c8e0c (diff)
downloadthatcomputerscientist-5cc36e5144e6e3bba259a837fa06321c547f49d8.tar.xz
thatcomputerscientist-5cc36e5144e6e3bba259a837fa06321c547f49d8.zip
fix cookie logging out
-rw-r--r--routes/auth.routes.js5
-rw-r--r--server.js9
-rw-r--r--site.config.yml2
3 files changed, 12 insertions, 4 deletions
diff --git a/routes/auth.routes.js b/routes/auth.routes.js
index dad0cc47..9615aa86 100644
--- a/routes/auth.routes.js
+++ b/routes/auth.routes.js
@@ -9,8 +9,9 @@ const validationString = process.env.AUTHORIZATION_STRING;
const connectionURL = process.env.DATABASE_URL;
router.get("/logout", (req, res) => {
- res.clearCookie("token");
- req.session.destroy();
+ res.clearCookie("token", {
+ domain: require("yaml").parse(require("fs").readFileSync("site.config.yml", "utf8")).domain,
+ });
res.redirect(req.get("referer"));
});
diff --git a/server.js b/server.js
index b48e3f17..1662868b 100644
--- a/server.js
+++ b/server.js
@@ -24,9 +24,16 @@ app.use(
},
secret: process.env.AUTHORIZATION_STRING,
resave: true,
- saveUninitialized: true
+ saveUninitialized: false
})
);
+app.use(function(req, res, next) {
+ res.header('Access-Control-Allow-Credentials', true);
+ res.header('Access-Control-Allow-Origin', req.headers.origin);
+ res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
+ res.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept');
+ next();
+});
app.use(flash());
app.use(
diff --git a/site.config.yml b/site.config.yml
index 4bcc3a8b..bf23097e 100644
--- a/site.config.yml
+++ b/site.config.yml
@@ -1,2 +1,2 @@
# This file contains all the global configuration for the website
-domain: '.thatcomputerscientist.com'
+domain: 'thatcomputerscientist.com'