Skip to content

Commit

Permalink
chore: set secure cookie from .env
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaillr committed Oct 22, 2024
1 parent fc3204c commit e86eb7c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const searchRoutes = require('./routes/search');
const logoutRoutes = require('./routes/logout');
const profileRoutes = require('./routes/profile');
const securityRoutes = require('./routes/security');
const adminRoutes = require('./routes/admin');
const imageRoutes = require("./routes/imageRoutes");

// Initialize Express app
const app = express();
Expand All @@ -46,7 +48,7 @@ app.use(session({
saveUninitialized: false,
cookie: {
maxAge: 1000 * 60 * 60 * 24, // Expires after 24 hours
secure: true // Secure only works over HTTPS
secure: process.env.COOKIE_SECURE // Secure only works over HTTPS
}
}));

Expand All @@ -72,6 +74,7 @@ app.use("/search", searchRoutes);
app.use("/logout", logoutRoutes);
app.use("/settings/profile", profileRoutes);
app.use("/settings/security", securityRoutes);
app.use("/admin", adminRoutes);

// Catch-all 404 handler for unavailable routes
app.use((req, res, next) => {
Expand Down

0 comments on commit e86eb7c

Please sign in to comment.