Fix project isolation: Make loadChatHistory respect active project sessions
- Modified loadChatHistory() to check for active project before fetching all sessions - When active project exists, use project.sessions instead of fetching from API - Added detailed console logging to debug session filtering - This prevents ALL sessions from appearing in every project's sidebar Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
42
debug_middleware.js
Normal file
42
debug_middleware.js
Normal file
@@ -0,0 +1,42 @@
|
||||
// Debug version of middleware
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function createCacheBustingMiddleware(version) {
|
||||
return function cacheBustingMiddleware(req, res, next) {
|
||||
console.log('[MIDDLEWARE] Request for:', req.path);
|
||||
|
||||
const originalSendFile = res.sendFile.bind(res);
|
||||
|
||||
res.sendFile = function(filePath, options, callback) {
|
||||
console.log('[MIDDLEWARE] sendFile called with:', filePath);
|
||||
console.log('[MIDDLEWARE] File extension check:', path.extname(filePath));
|
||||
|
||||
if (filePath && (filePath.endsWith('.html') || filePath.endsWith('.htm'))) {
|
||||
console.log('[MIDDLEWARE] Processing HTML file');
|
||||
try {
|
||||
const data = fs.readFileSync(filePath, 'utf8');
|
||||
console.log('[MIDDLEWARE] File read successfully, length:', data.length);
|
||||
|
||||
// Simple test: add comment
|
||||
const modifiedHtml = data.replace('</head>', '<!-- cache-busted -->\n</head>');
|
||||
|
||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||
res.send(modifiedHtml);
|
||||
|
||||
if (callback) callback();
|
||||
} catch (err) {
|
||||
console.error('[MIDDLEWARE] Error:', err);
|
||||
return originalSendFile(filePath, options, callback);
|
||||
}
|
||||
} else {
|
||||
console.log('[MIDDLEWARE] Not an HTML file, using original');
|
||||
return originalSendFile(filePath, options, callback);
|
||||
}
|
||||
};
|
||||
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { createCacheBustingMiddleware };
|
||||
Reference in New Issue
Block a user