Update server/src/index.js

This commit is contained in:
2025-11-13 16:49:26 +00:00
parent 1abbf9b506
commit 48149bb17b

View File

@@ -6,6 +6,8 @@ import cookieParser from 'cookie-parser';
import http from 'http';
import { Server as IOServer } from 'socket.io';
import jwt from 'jsonwebtoken';
import path from 'path';
import { fileURLToPath } from 'url';
import { init as dbInit, Characters, Inventory, query } from './db.js';
@@ -94,8 +96,11 @@ app.get('/api/me', async (req, res) => {
res.json({ character: ch, inventory: inv, world: WORLD });
});
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Serve client
app.use(express.static(new URL('../static', import.meta.url).pathname));
app.use(express.static(path.join(__dirname, '../static')));
const server = http.createServer(app);
const io = new IOServer(server, {