Skip to content

Commit

Permalink
fix: properly resolve relative file
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Nov 17, 2023
1 parent c4c0784 commit 07a183a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import express from 'express';
import { createServer } from 'node:http';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
import { Server } from 'socket.io';
import sqlite3 from 'sqlite3';
import { open } from 'sqlite';
Expand Down Expand Up @@ -37,8 +39,10 @@ if (cluster.isPrimary) {
adapter: createAdapter()
});

const __dirname = dirname(fileURLToPath(import.meta.url));

app.get('/', (req, res) => {
res.sendFile(new URL('./index.html', import.meta.url).pathname);
res.sendFile(join(__dirname, 'index.html'));
});

io.on('connection', async (socket) => {
Expand Down

0 comments on commit 07a183a

Please sign in to comment.