Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session name and secure cookies #83

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));

// initialise openai
initOpenAi();
Expand Down Expand Up @@ -55,4 +61,4 @@ app.use(function (req, res, next) {
app.use("/", router);
app.listen(port, () => {
console.log("Server is running on port: " + port);
});
});