diff --git a/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx b/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx index 089b7f1..0969f58 100644 Binary files a/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx and b/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx differ diff --git a/renderer/carbone-templates/registry.json b/renderer/carbone-templates/registry.json index 4ceb2f0..3834aa3 100644 --- a/renderer/carbone-templates/registry.json +++ b/renderer/carbone-templates/registry.json @@ -5,6 +5,7 @@ "filename": "433a0593-d3cf-414e-8763-ab5f87cbc75c.docx", "originalName": "master_cv_template.docx", "path": "/root/workspace/cv-app/renderer/carbone-templates/433a0593-d3cf-414e-8763-ab5f87cbc75c.docx", - "uploadedAt": "2026-07-16T09:03:29.601Z" + "uploadedAt": "2026-07-16T09:03:29.601Z", + "updatedAt": "2026-07-16T11:09:51.737Z" } ] \ No newline at end of file diff --git a/renderer/onlyoffice-service.js b/renderer/onlyoffice-service.js index 6c4df80..a5aaa40 100644 --- a/renderer/onlyoffice-service.js +++ b/renderer/onlyoffice-service.js @@ -109,8 +109,12 @@ function verifyToken(token) { * ONLYOFFICE uses this to identify document sessions and for caching. * Must be unique per document + version (so re-edits get fresh sessions). */ -function generateDocKey(templateId) { - return `cvtemplate_${templateId}_${Date.now()}_${crypto.randomBytes(4).toString('hex')}`; +function generateDocKey(templateId, fileMtime) { + // Include the file's modification time in the key so that + // when the file is updated via callback, the next edit session + // gets a completely new key and ONLYOFFICE fetches the fresh file + const mtime = fileMtime || Date.now(); + return `cvtemplate_${templateId}_${mtime}_${crypto.randomBytes(4).toString('hex')}`; } // ============================================================ @@ -131,14 +135,16 @@ router.get('/:templateId/config', (req, res) => { return res.status(404).json({ error: 'Template file missing' }); } - const docKey = generateDocKey(templateId); + // Get file modification time for cache-busting doc key + const fileStats = fs.statSync(template.path); + const fileMtime = fileStats.mtimeMs; + const docKey = generateDocKey(templateId, fileMtime); const fileName = template.originalName || template.name + '.docx'; - // Build the editor config - // The document URL must be accessible from ONLYOFFICE's perspective. - // In Docker: http://cv-backend:8771/api/onlyoffice//download - // In dev: http://:8771/api/onlyoffice//download - const documentUrl = `${BACKEND_PUBLIC_URL}/api/onlyoffice/${templateId}/download`; + // Add cache-busting timestamp to the document URL so ONLYOFFICE + // always fetches the latest version from our backend + const cacheBuster = Date.now(); + const documentUrl = `${BACKEND_PUBLIC_URL}/api/onlyoffice/${templateId}/download?cb=${cacheBuster}`; const callbackUrl = `${BACKEND_PUBLIC_URL}/api/onlyoffice/${templateId}/callback`; const config = {