diff --git a/src/server.ts b/src/server.ts index 81a69a4f..e319f9c6 100644 --- a/src/server.ts +++ b/src/server.ts @@ -8,6 +8,7 @@ import http from "node:http"; import type { AddressInfo } from "node:net"; import path from 'node:path'; +import { fileURLToPath } from 'node:url'; import { autoDetect } from '@serialport/bindings-cpp'; import type { PortInfo } from "@serialport/bindings-interface"; import cors from "cors"; @@ -46,7 +47,8 @@ const getDeviceInfo = (ebb: EBB | null, _com: Com) => { */ export async function startServer(port: number, hardware: Hardware = 'v3', com: Com = null, enableCors = false, maxPayloadSize = '200mb', svgIoApiKey = '') { const app = express(); - app.use('/', express.static(path.join(path.resolve(), 'dist', 'ui'))); + const __dirname = path.dirname(fileURLToPath(import.meta.url)); + app.use('/', express.static(path.join(__dirname, '..', 'ui'))); app.use(express.json({ limit: maxPayloadSize })); if (enableCors) { app.use(cors()); diff --git a/tsconfig.json b/tsconfig.json index 6656763e..b20b3d6c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "target": "es2022", - "module": "es2022", + "module": "es2020", "moduleResolution": "node", "esModuleInterop": true, "noImplicitAny": true,