mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #472] feat: support assetPrefix in next.config #103
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#103
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @elydelva on GitHub (Mar 11, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/472
Summary
assetPrefixfromnext.configis currently not read or used anywhere in vinext. Setting it is silently ignored.Current behavior
In production, all static assets (fonts, JS chunks, etc.) are always served from:
The URL is generated by Vite's asset pipeline with no way to inject a CDN prefix.
Expected behavior
When
assetPrefixis set innext.config:All asset URLs should be prefixed accordingly:
Why this matters
When deploying to Cloudflare Workers with a gateway pattern (a hub Worker routing requests to multiple service Workers), every request — including static assets like fonts and images — goes through the gateway Worker and incurs an invocation.
With
assetPrefixsupport, static assets could be served from a dedicated subdomain (e.g.assets-app.example.com) backed by a Cloudflare Workers Assets-only deployment withrun_worker_first: false. This would serve fonts, CSS, and JS bundles directly from Cloudflare's edge with zero Worker invocations.Investigation
Verified by reading
dist/config/next-config.js—resolveNextConfignever extractsassetPrefix. Thevinext:local-fontsVite plugin (index.js lines 3153–3219) rewrites font paths to Vite static asset imports, but Vite'sbase(driven bybasePath) is the only configurable prefix — there is noassetPrefixinjection at any stage.Suggested approach
In
resolveNextConfig, extractassetPrefixand pass it through to the Vite plugin. The plugin would then configure Vite'sexperimental.renderBuiltUrlto prefix resolved asset URLs:This would cover JS/CSS chunks, font files, and images processed through Vite's asset pipeline.