Static implementation guide
Asset Prefix Routing
Serve an origin project’s hashed Next.js JavaScript and CSS through the same public prefix as its rewritten HTML.
Last updated 2026-08-23
Why document rewrites are not enough
A successful HTML response can still produce a broken page if its scripts and styles point at a path the gateway does not forward. Next.js emits build artifacts under the _next static directory. Setting an asset prefix causes the generated document to reference that directory beneath the chosen public prefix, so the browser continues to request every resource from the gateway hostname.
The prefix is deliberately shared with the content route. One external rewrite can therefore carry guide documents and hashed assets to the origin. The origin adds an internal rewrite from the prefixed _next route to the real build output, which avoids using a global base path and leaves the origin robots file at the host root.
Verify generated assets end to end
Build the origin first, fetch a generated guide through the gateway, and extract its script and stylesheet URLs from the raw HTML. Every referenced prefixed asset should return 200 through the gateway. Network inspection should show the public host for the document, JavaScript, and CSS, with no direct browser request to the origin hostname.
Hashed static assets can receive a much longer gateway TTL than HTML because their URL changes when their content changes. Public-folder files do not automatically inherit assetPrefix, so this test uses CSS and inline presentation instead of unprefixed media that could obscure the routing result.