diff --git a/src/server.mjs b/src/server.mjs index 4e9ed82..21e4d0d 100644 --- a/src/server.mjs +++ b/src/server.mjs @@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto'; import fs from 'node:fs'; import http from 'node:http'; import path from 'node:path'; -import { fileURLToPath, pathToFileURL } from 'node:url'; +import { fileURLToPath } from 'node:url'; import { signPayload } from '../lib/signPayload.mjs'; @@ -190,8 +190,10 @@ export function createServer(options = {}) { }); } +const entryPath = process.argv[1] ? path.resolve(process.argv[1]) : ''; const isMain = - process.argv[1] && pathToFileURL(path.resolve(process.argv[1])).href === import.meta.url; + entryPath !== '' && + (fileURLToPath(import.meta.url) === entryPath || entryPath.endsWith(`${path.sep}server.mjs`)); if (isMain) { const privateKeyPem = process.env.LICENSE_PRIVATE_KEY_PEM;