diff --git a/server/src/index.js b/server/src/index.js index 0b08d9f..bef6749 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -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, {