You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Routing virtual modules interpolate raw handler paths, breaking late-registered handlers on Windows #4907
The #nitro/virtual/routing and #nitro/virtual/routing-meta templates interpolate h.handler directly into string literals:
`import ${h._importHash} from "${h.handler}";``const ${h._importHash} = h3.defineLazyEventHandler(() => import("${h.handler}"));``import ${h._importHash}Meta from "${h.handler}?meta";`
Handler paths are only normalized by resolveNitroPath() while options are resolved. A handler pushed to nitro.options.handlers afterwards (from a module or hook, followed by nitro.routing.sync()) keeps whatever path it was given. On Windows a node:path path such as C:\app\.nitro\workflow\handler.mjs ends up as "C:\app\.nitro\workflow\handler.mjs" in generated code. The backslashes are read as escape sequences, so the specifier is silently mangled or the module fails to parse (\x, \u).
Works on POSIX and breaks on Windows. Emitting the specifier with JSON.stringify() after normalizing it (forward slashes, or a file:// URL for drive-letter paths), or normalizing handler paths in routing.sync(), would make late-registered handlers behave like config-time ones.
eve works around this with a transform on both virtual ids that rewrites drive-letter specifiers to file:// URLs (nitro-routing-import-specifier-plugin.ts), and would drop it once Nitro handles this.
Found by reading the generated templates in [email protected]; not reproduced on a Windows machine for this report.
Activity