Skip to content

Commit

Permalink
Secure flag is only enabled in production
Browse files Browse the repository at this point in the history
  • Loading branch information
navodveduth committed Sep 19, 2024
1 parent 0986ce2 commit d08bb15
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion BackEnd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ app.use(cookieParser());

// Enable CSRF protection for state-changing routes (POST, PUT, DELETE)
const csrfProtection = csurf({
cookie: true, // Store CSRF token in a cookie
cookie: {
httpOnly: true, // Prevents JavaScript from accessing the cookie
secure: process.env.NODE_ENV === 'production', // Only set the secure flag in production
},
});

// Use middleware to increment visitor count
Expand Down

0 comments on commit d08bb15

Please sign in to comment.