Add PWA support and miner race
This commit is contained in:
@@ -28,6 +28,8 @@ export function buildApp() {
|
||||
"img-src": ["'self'", "data:"],
|
||||
"connect-src": ["'self'", "wss://relay.primal.net"],
|
||||
"font-src": ["'self'", "data:"],
|
||||
"manifest-src": ["'self'"],
|
||||
"worker-src": ["'self'"],
|
||||
"frame-ancestors": ["'none'"],
|
||||
"upgrade-insecure-requests": null,
|
||||
},
|
||||
@@ -67,10 +69,21 @@ export function buildApp() {
|
||||
|
||||
if (staticDir && fs.existsSync(staticDir)) {
|
||||
logger.info({ staticDir }, "serving web assets");
|
||||
app.use(express.static(staticDir, { index: false, maxAge: "1h" }));
|
||||
app.use(
|
||||
express.static(staticDir, {
|
||||
index: false,
|
||||
maxAge: "1h",
|
||||
setHeaders: (res, filePath) => {
|
||||
if (filePath.endsWith("sw.js") || filePath.endsWith("manifest.webmanifest")) {
|
||||
res.setHeader("Cache-Control", "no-cache");
|
||||
}
|
||||
},
|
||||
}),
|
||||
);
|
||||
app.get(/.*/, (_req, res, next) => {
|
||||
const indexFile = path.join(staticDir, "index.html");
|
||||
if (!fs.existsSync(indexFile)) return next();
|
||||
res.setHeader("Cache-Control", "no-cache");
|
||||
res.sendFile(indexFile);
|
||||
});
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user