Fix version check in server.js template with error handling
Added robust error handling for dynamic version retrieval in the server.js template: - Added try/catch block around package.json require - Added fallback version if package.json can't be loaded - Ensures server will start even if there's an issue loading the version This prevents connection errors related to the version check functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
		| @@ -266,8 +266,13 @@ app.use(bodyParser.urlencoded({ extended: true, limit: '50mb' })); | ||||
| //============================== | ||||
|  | ||||
| // Get the version from package.json | ||||
| const packageJson = require('./package.json'); | ||||
| const appVersion = packageJson.version; | ||||
| let appVersion = '2.0.6'; // Default fallback version | ||||
| try { | ||||
|   const packageJson = require('./package.json'); | ||||
|   appVersion = packageJson.version; | ||||
| } catch (err) { | ||||
|   console.warn('Could not read version from package.json, using default'); | ||||
| } | ||||
|  | ||||
| // Server status API | ||||
| app.get('/api/status', (req, res) => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user