Downgrade css to prevent older browsers displaying faulty views
Sonarqube Scanner / Build and analyze (push) Failing after 1m36s
Sonarqube Scanner / Build and analyze (push) Failing after 1m36s
This commit is contained in:
@@ -10,6 +10,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
ensureRuntimeDirectories();
|
||||
const db = openDatabase();
|
||||
const app = express();
|
||||
const publicDirectory = path.join(__dirname, 'public');
|
||||
|
||||
app.disable('x-powered-by');
|
||||
app.use(express.json({
|
||||
@@ -18,17 +19,22 @@ app.use(express.json({
|
||||
}));
|
||||
app.use(express.urlencoded({ extended: true, limit: '2mb' }));
|
||||
app.use('/api', createApiRouter(db));
|
||||
app.use(express.static(path.join(__dirname, 'public'), {
|
||||
app.use(express.static(publicDirectory, {
|
||||
extensions: ['html'],
|
||||
etag: true,
|
||||
lastModified: true,
|
||||
maxAge: 0,
|
||||
setHeaders(res, filePath) {
|
||||
if (filePath.endsWith('.html')) {
|
||||
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||
return;
|
||||
const extension = path.extname(filePath).toLowerCase();
|
||||
const authoredAsset = ['.html', '.css', '.js'].includes(extension);
|
||||
res.setHeader(
|
||||
'Cache-Control',
|
||||
authoredAsset ? 'no-cache, no-store, must-revalidate' : 'public, max-age=0, must-revalidate'
|
||||
);
|
||||
if (authoredAsset) {
|
||||
res.setHeader('Pragma', 'no-cache');
|
||||
res.setHeader('Expires', '0');
|
||||
}
|
||||
res.setHeader('Cache-Control', 'public, max-age=0, must-revalidate');
|
||||
}
|
||||
}));
|
||||
app.use(notFoundHandler);
|
||||
|
||||
Reference in New Issue
Block a user