Skip to content

Commit

Permalink
Session name and secure cookies (#83)
Browse files Browse the repository at this point in the history
* Added session name and security

* Removed unsued import
  • Loading branch information
gsproston-scottlogic authored Aug 8, 2023
1 parent d49e02f commit a09c06c
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions backend/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ const port = process.env.PORT || 3001;
const app = express();
// for parsing application/json
app.use(express.json());

// use session
app.use(
session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: true,
})
);
const sess = {
secret: process.env.SESSION_SECRET,
name: "prompt-injection.sid",
resave: false,
saveUninitialized: true,
cookie: {},
};
// serve secure cookies in production
if (app.get("env") === "production") {
sess.cookie.secure = true;
}
app.use(session(sess));

// main model for chat
initOpenAi();
Expand Down Expand Up @@ -58,4 +64,4 @@ app.use(function (req, res, next) {
app.use("/", router);
app.listen(port, () => {
console.log("Server is running on port: " + port);
});
});

0 comments on commit a09c06c

Please sign in to comment.