Skip to content
Open
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
11 changes: 10 additions & 1 deletion server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ app.use(session({
secret: process.env.COOKIE_SECRET,
cookie: {
httpOnly: true,
secure: false,
secure: process.env.NODE_ENV === 'production', // Use secure cookies in production
domain: 'example.com', // Set your domain
path: '/', // Set path to root
expires: new Date(Date.now() + 60 * 60 * 1000), // Set expiration to 1 hour
},
name: 'session-cookie',
}));
Expand Down Expand Up @@ -127,6 +130,12 @@ const fs = require('fs');

app.get('/:page', (req, res) => {
const page = req.params.page;
const allowedPages = ['home', 'about', 'contact']; // Allow list for pages

if (!allowedPages.includes(page)) {
return res.status(403).send('Forbidden');
}

const filePath = path.join(__dirname, 'views', `${page}.html`);

fs.access(filePath, fs.constants.F_OK, (err) => {
Expand Down