diff --git a/lib/router.js b/lib/router.js index 27e56e0..245f34f 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1,4 +1,5 @@ import path from 'node:path'; +import { pathToFileURL } from 'node:url'; import { readdir } from 'node:fs/promises'; import Channel from './channel.js'; import config from '../config.js'; @@ -55,7 +56,9 @@ const loadRoutes = async () => { const files = (await readdir(config.ROUTES_DIR)).sort(); for (const file of files) { if (!file.endsWith('.js') || file === 'static.js') continue; - const mod = await import(path.join(config.ROUTES_DIR, file)); + const routePath = path.join(config.ROUTES_DIR, file); + const routeUrl = pathToFileURL(routePath).href; + const mod = await import(routeUrl); if (!isRouteMap(mod.default)) continue; table[path.basename(file, '.js')] = makeHandler(mod.default); }