From 66ad61b8a053bd90ca51e226981a74a96179e37d Mon Sep 17 00:00:00 2001 From: MrPiglr Date: Thu, 12 Feb 2026 12:55:59 -0700 Subject: [PATCH] fix(server): add root healthcheck endpoint for Railway deployment - Add root '/' endpoint that responds with JSON status - Make download routes handle missing installers gracefully - Add error handling around download routes registration - Add logging for download routes initialization Fixes Railway healthcheck failures by ensuring server responds at root path --- server/download-routes.ts | 6 ++++-- server/index.ts | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/server/download-routes.ts b/server/download-routes.ts index fcb662d..ad60be4 100644 --- a/server/download-routes.ts +++ b/server/download-routes.ts @@ -22,9 +22,11 @@ router.get('/desktop', async (req, res) => { // Check if file exists if (!fs.existsSync(installerPath)) { + console.log('[Download] Installer not found at', installerPath); return res.status(404).json({ - error: 'Installer not found', - message: 'The desktop installer has not been built yet. Please run: npm run build:tauri' + error: 'Installer not available', + message: 'The desktop installer is not yet available. It will be uploaded soon.', + note: 'For development: Run "npm run build:tauri" in shell/aethex-shell to build the installer' }); } diff --git a/server/index.ts b/server/index.ts index b31fea3..da00af1 100644 --- a/server/index.ts +++ b/server/index.ts @@ -25,6 +25,21 @@ app.get("/health", (_req, res) => { res.json({ status: "healthy", timestamp: new Date().toISOString() }); }); +// Root health check (Railway uses this) +app.get("/", (_req, res) => { + res.json({ + status: "online", + service: "AeThex OS API", + version: "1.0.0", + timestamp: new Date().toISOString(), + endpoints: { + web: "Use client to access web interface", + api: "/api/*", + download: "/api/download/*" + } + }); +}); + // API status endpoint (moved from root to /api/status) app.get("/api/status", (_req, res) => { const isKernel = process.env.OPS_Version ? true : false; @@ -132,8 +147,14 @@ app.use((req, res, next) => { (async () => { - // Register download routes - app.use('/api/download', downloadRoutes); + // Register download routes (wrapped in try-catch for safety) + try { + app.use('/api/download', downloadRoutes); + log("Download routes registered", "express"); + } catch (error) { + log(`Warning: Failed to register download routes: ${error}`, "express"); + // Continue anyway - app can work without download routes + } // Register routes (org middleware applied selectively within routes.ts) await registerRoutes(httpServer, app);