{"record":{"id":"a2ee11418fbaef06","repo":"davila7/claude-code-templates","slug":"not-found","errorCode":null,"errorMessage":"Not found","messagePattern":"Not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"cli-tool/src/chats-mobile.js","lineNumber":811,"sourceCode":"          error: 'Failed to fetch analytics',\n          message: error.message\n        });\n      }\n    });\n\n    // Serve the mobile chats page as default\n    this.app.get('/', (req, res) => {\n      res.sendFile(path.join(__dirname, 'analytics-web', 'chats_mobile.html'));\n    });\n\n    // Fallback for any other routes (but not for API or static files)\n    this.app.get('*', (req, res) => {\n      // Don't redirect API calls or static files\n      if (req.path.startsWith('/api/') || \n          req.path.startsWith('/services/') || \n          req.path.startsWith('/components/') || \n          req.path.startsWith('/assets/')) {\n        res.status(404).json({ error: 'Not found' });\n        return;\n      }\n      res.sendFile(path.join(__dirname, 'analytics-web', 'chats_mobile.html'));\n    });\n  }\n\n  /**\n   * Setup file watching for Claude Code conversations\n   */\n  async setupFileWatching() {\n    try {\n      const homeDir = os.homedir();\n      const claudeDir = path.join(homeDir, '.claude');\n      \n      this.fileWatcher.setupFileWatchers(\n        claudeDir,\n        this.handleDataRefresh.bind(this),\n        () => {}, // processRefreshCallback (not needed for mobile)","sourceCodeStart":793,"sourceCodeEnd":829,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/chats-mobile.js#L793-L829","documentation":"This is the Express fallback route's 404 for unmatched API/service/component/asset paths. Any GET whose path starts with /api/, /services/, /components/, or /assets/ but matches no earlier route gets this JSON 404 instead of being served the SPA HTML file.","triggerScenarios":"Calling an API endpoint that doesn't exist (typo like /api/conversation/:id/analytics, wrong prefix) or requesting a missing asset like /assets/nonexistent.js — the fallback sees the /assets/ prefix and returns 404 JSON rather than index.html.","commonSituations":"Version mismatch where the frontend HTML references a hashed asset that a newer/older server build doesn't ship; curl-ing an endpoint after a route rename; proxying requests to the wrong port so they hit chats-mobile instead of the intended service.","solutions":["Compare the requested path against the routes actually defined in setupRoutes (grep this.app.get/post in chats-mobile.js)","If it's an asset 404, clear cache / hard-refresh so the UI reloads HTML matching the served assets","Make sure you're hitting the right server/port (chats-mobile vs other local dashboards)","Fix the typo or update the client to the current API path"],"exampleFix":"// before\nfetch('/api/conversations/analytics'); // -> 404 { error: 'Not found' }\n// after\nfetch('/api/conversations/' + encodeURIComponent(id) + '/analytics');","handlingStrategy":"validation","validationCode":"const KNOWN = ['/api/conversations', /^\\/api\\/conversations\\/[^/]+\\/analytics$/];\nif (!KNOWN.some(p => typeof p === 'string' ? path === p : p.test(path))) console.warn('unmatched route', path);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize API path constants instead of string-concatenating endpoints","Log the failing path on 404 to catch typos early","Hard-refresh after server upgrades so assets and routes stay in sync"],"tags":["http-404","express","fallback-route","routing"],"backgroundTag":"http-404-not-found","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}