[GH-ISSUE #728] Support file:// URLs from import.meta.resolve() in cacheHandler config path #158

Closed
opened 2026-05-06 12:37:44 +02:00 by BreizhHardware · 0 comments

Originally created by @github-actions[bot] on GitHub (Mar 31, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/728

Next.js Change

Commit: 9a0214a1
PR: #90370

Next.js now handles file:// URLs in the cacheHandler config path. When "type": "module" is set in package.json, users must use import.meta.resolve() instead of require.resolve() to resolve the cache handler path. import.meta.resolve() returns a file:// URL, which previously broke path operations like path.join and path.relative, producing invalid paths and ERR_MODULE_NOT_FOUND errors.

The fix adds a resolveCacheHandlerPathToFilesystem() helper that converts file:// URLs to filesystem paths using Node's fileURLToPath() before any path operations.

Relevance to vinext

vinext supports the cacheHandler config option for pluggable cache backends (ISR cache, KV cache handler for Cloudflare Workers). If vinext resolves or manipulates the cacheHandler path from next.config.js using path.join, path.relative, or similar path operations, it needs the same file:// URL handling to avoid broken paths in ESM projects.

What to implement

  • When processing the cacheHandler (or cacheHandlers) config value, check if the path starts with file:// and convert it to a filesystem path using node:url's fileURLToPath() before any path operations.
Originally created by @github-actions[bot] on GitHub (Mar 31, 2026). Original GitHub issue: https://github.com/cloudflare/vinext/issues/728 ## Next.js Change **Commit:** [`9a0214a1`](https://github.com/vercel/next.js/commit/9a0214a12f1ed1901c4b01e84073ab854848eea0) **PR:** [#90370](https://github.com/vercel/next.js/pull/90370) Next.js now handles `file://` URLs in the `cacheHandler` config path. When `"type": "module"` is set in `package.json`, users must use `import.meta.resolve()` instead of `require.resolve()` to resolve the cache handler path. `import.meta.resolve()` returns a `file://` URL, which previously broke path operations like `path.join` and `path.relative`, producing invalid paths and `ERR_MODULE_NOT_FOUND` errors. The fix adds a `resolveCacheHandlerPathToFilesystem()` helper that converts `file://` URLs to filesystem paths using Node's `fileURLToPath()` before any path operations. ## Relevance to vinext vinext supports the `cacheHandler` config option for pluggable cache backends (ISR cache, KV cache handler for Cloudflare Workers). If vinext resolves or manipulates the `cacheHandler` path from `next.config.js` using `path.join`, `path.relative`, or similar path operations, it needs the same `file://` URL handling to avoid broken paths in ESM projects. ## What to implement - When processing the `cacheHandler` (or `cacheHandlers`) config value, check if the path starts with `file://` and convert it to a filesystem path using `node:url`'s `fileURLToPath()` before any path operations.
BreizhHardware 2026-05-06 12:37:44 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#158
No description provided.