Fix hardcoded 1.2.4 values - make frontend load current version from API on mount and update User-Agent dynamically

This commit is contained in:
Muhammad Ibrahim
2025-09-20 14:49:05 +01:00
parent d687ec4e45
commit 9a3827dced
2 changed files with 31 additions and 2 deletions

View File

@@ -202,11 +202,22 @@ class UpdateScheduler {
try {
const httpsRepoUrl = `https://api.github.com/repos/${owner}/${repo}/releases/latest`;
// Get current version for User-Agent
let currentVersion = '1.2.5'; // fallback
try {
const packageJson = require('../../package.json');
if (packageJson && packageJson.version) {
currentVersion = packageJson.version;
}
} catch (packageError) {
console.warn('Could not read version from package.json for User-Agent, using fallback:', packageError.message);
}
const response = await fetch(httpsRepoUrl, {
method: 'GET',
headers: {
'Accept': 'application/vnd.github.v3+json',
'User-Agent': 'PatchMon-Server/1.2.4'
'User-Agent': `PatchMon-Server/${currentVersion}`
}
});