Skip to content

Commit fe1efaa

Browse files
committed
use abolute paths
1 parent 597fc8e commit fe1efaa

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "mcp-analytics-middleware",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "Analytics middleware for Model Context Protocol servers",
55
"main": "dist/src/index.js",
66
"type": "module",
77
"files": [
88
"dist",
9+
"web-viewer/public",
910
"README.md",
1011
"LICENSE"
1112
],

web-viewer/server.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ import express, { Request, Response } from 'express';
44
import cors from 'cors';
55
import { McpAnalytics } from '../src/index.js';
66
import path from 'path';
7+
import { fileURLToPath } from 'url';
8+
9+
// Get the directory where this file is located
10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename);
12+
const packageDir = path.resolve(__dirname, '..');
713

814
const app = express();
915
app.use(cors());
1016
app.use(express.json());
11-
app.use(express.static(path.join(process.cwd(), 'dist/web-viewer/public')));
17+
18+
// Use the package directory instead of the current working directory
19+
app.use(express.static(path.join(packageDir, 'web-viewer/public')));
1220

1321
// Get database path from command line args
1422
let dbPath: string | undefined = undefined;
@@ -74,7 +82,7 @@ app.get('/api/tools/daily', (_req: Request, res: Response) => {
7482
// Add a fallback route to serve the index.html for any unknown routes
7583
// This is necessary for client-side routing to work
7684
app.get('*', (_req: Request, res: Response) => {
77-
res.sendFile(path.join(process.cwd(), 'dist/web-viewer/public/index.html'));
85+
res.sendFile(path.join(packageDir, 'web-viewer/public/index.html'));
7886
});
7987

8088
const port = process.env.PORT || 8080;

0 commit comments

Comments
 (0)