Add universal cursor hover-to-translate detector and cache-busting headers
This commit is contained in:
1 parent
e8aef17029
commit
e636350940
4 files changed
+206
-32
No files matched your search
+9
-1
@@ -185,8 +185,16 @@ app.get('/api/translate', async (req, res) => {
|
||||
res.json({ word, english: null });
|
||||
});
|
||||
|
||||
// Serve static frontend files from project root
|
||||
// Serve static frontend files from project root with no-cache headers so updates apply immediately
|
||||
const PUBLIC_DIR = path.resolve(__dirname, '..');
|
||||
app.use((req, res, next) => {
|
||||
if (!req.path.startsWith('/api/tts')) {
|
||||
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||
res.setHeader('Pragma', 'no-cache');
|
||||
res.setHeader('Expires', '0');
|
||||
}
|
||||
next();
|
||||
});
|
||||
app.use('/data', express.static(path.join(PUBLIC_DIR, 'data')));
|
||||
app.get('/styles.css', (_req, res) => res.sendFile(path.join(PUBLIC_DIR, 'styles.css')));
|
||||
app.get('/app.js', (_req, res) => res.sendFile(path.join(PUBLIC_DIR, 'app.js')));
|
||||
|
||||
Reference in new issue
Block a user