M Whitaker
M Whitaker
NNuxt
Created by M Whitaker on 4/3/2024 in #❓・help
Protecting static folder on server side
It should, but sadly not for me so far. 🤷‍♂️ But will check out the Nitro docs- thanks for the pointer!
7 replies
NNuxt
Created by M Whitaker on 4/3/2024 in #❓・help
Protecting static folder on server side
Just for future reference, the use case I described is trivial with express:
import express from 'express';
const app = express();
/ Protect the protected folder
app.use('/protected', (req, res, next) => {
if (req.session.authenticated) {
// Serve files from the protected folder
next();
} else {
// Deny access or redirect to login page
res.status(403).send('Access denied');
}
});

// Serve files from the protected folder
app.use('/protected', express.static(path.join(path.resolve(), 'dist')));
import express from 'express';
const app = express();
/ Protect the protected folder
app.use('/protected', (req, res, next) => {
if (req.session.authenticated) {
// Serve files from the protected folder
next();
} else {
// Deny access or redirect to login page
res.status(403).send('Access denied');
}
});

// Serve files from the protected folder
app.use('/protected', express.static(path.join(path.resolve(), 'dist')));
7 replies
NNuxt
Created by M Whitaker on 4/3/2024 in #❓・help
Protecting static folder on server side
it's an internal dashboard built with Observable that I only want to show to logged in users. Observable framework has their own cli to build those static HTML files and assets. I'll check into Nitro, but I suspect it will be tricky to serve that folder. only to logged in users. Many thanks for responding!
7 replies