Workers, Cloudflare CLI - Serve Workers Static Assets from a URL path prefix
- Announced
- Tags
- Workers, Cloudflare-CLI
- Severity
- info, set by
reef/rss-rule-v1 - Source
- https://developers.cloudflare.com/changelog/post/2026-10-28-static-assets-base-path/
<p>Workers Static Assets can now serve assets from a URL path prefix without changing their directory structure. Set <code>assets.base_path</code> in Wrangler, or <code>worker.assets.basePath</code> in <code>cloudflare.config.ts</code>.</p> <p>Use <a href="https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.148.0" target="_blank" rel="noopener">Wrangler 4.148.0<span class="external-link"> ↗︎</span></a> or later. With <code>cloudflare.config.ts</code>, use <a href="https://github.com/cloudflare/cf/releases/tag/cf%401.0.0-beta.13" target="_blank" rel="noopener"><code>cf</code> 1.0.0-beta.13<span class="external-link"> ↗︎</span></a> or later.</p> <p>For example, this configuration serves your built assets from <code>/blog/</code>:</p> <div data-nb-cli-preference-scope class="w-full"><div data-nb-cli-control style="visibility: hidden" class="mb-2 flex min-w-0 items-center justify-end gap-2"><span id="cli-preference-74234e98-label" class="text-muted-foreground text-xs font-medium">Select your preferred CLI</span><div role="group" aria-labelledby="cli-preference-74234e98-label" aria-describedby="cli-preference-74234e98-help" class="ring-border/70 inline-flex h-6.5 max-w-full min-w-0 rounded-md bg-[var(--nb-surface-sunken)] px-0.5 ring"><button type="button" data-nb-cli-toggle="wrangler" aria-pressed="true" disabled class="text-muted-foreground hover:text-foreground aria-pressed:bg-card aria-pressed:text-foreground aria-pressed:ring-border focus-visible:ring-primary relative z-1 my-0.5 cursor-pointer rounded-sm border-0 px-2 text-xs font-medium whitespace-nowrap shadow-none transition-[color,background-color,box-shadow] focus-visible:ring-2 focus-visible:outline-none focus-visible:ring-inset aria-pressed:shadow-sm aria-pressed:ring">Wrangler</button><button type="button" data-nb-cli-toggle="cf" aria-pressed="false" disabled class="text-muted-foreground hover:text-foreground aria-pressed:bg-card aria-pressed:text-foreground aria-pressed:ring-border focus-visible:ring-primary relative z-1 my-0.5 cursor-pointer rounded-sm border-0 px-2 text-xs font-medium whitespace-nowrap shadow-none transition-[color,background-color,box-shadow] focus-visible:ring-2 focus-visible:outline-none focus-visible:ring-inset aria-pressed:shadow-sm aria-pressed:ring">CF</button></div><span id="cli-preference-74234e98-help" class="sr-only">Changes examples on this page to use the selected CLI.</span><span data-nb-cli-status role="status" class="sr-only"></span></div><script type="module" src="https://developers.cloudflare.com/home/runner/work/cloudflare-docs/cloudflare-docs/src/components/ui/cli-preference/CliPreferenceSelector.astro?astro&type=script&index=0&lang.ts"></script><div data-nb-cli-variant="wrangler"><div data-nb-tabs data-nb-sync-key="wranglerConfig" class><div class="relative flex border-b border-border" role="tablist" data-nb-tabs-list><span class="bg-primary pointer-events-none absolute -bottom-px h-0.5 rounded-t-sm transition-[left,width] duration-200 ease-out" data-nb-tabs-indicator aria-hidden="true"></span></div><div class="mt-3"><div role="tabpanel" data-nb-tabs-content data-nb-tab-label="wrangler.jsonc" class><figure class="nb-code-figure" data-nb-lang="jsonc"><pre class="astro-code astro-code-themes github-light github-dark nb-shiki-c6xiwz" tabindex="0" data-language="jsonc" data-nb-lang="jsonc"><code><span class="line"><span class="nb-shiki-140thh">{</span></span> <span class="line"><span class="nb-shiki-dzsirb"> "$schema"</span><span class="nb-shiki-140thh">: </span><span class="nb-shiki-mdbnqw">"./node_modules/wrangler/config-schema.json"</span><span class="nb-shiki-140thh">,</span></span> <span class="line"><span class="nb-shiki-dzsirb"> "assets"</span><span class="nb-shiki-140thh">: {</span></span> <span class="line"><span class="nb-shiki-dzsirb"> "directory"</span><span class="nb-shiki-140thh">: </span><span class="nb-shiki-mdbnqw">"./dist"</span><span class="nb-shiki-140thh">,</span></span> <span class="line"><span class="nb-shiki-dzsirb"> "base_path"</span><span class="nb-shiki-140thh">: </span><span class="nb-shiki-mdbnqw">"/blog"</span></span> <span class="line"><span class="nb-shiki-140thh"> }</span></span> <span class="line"><span class="nb-shiki-140thh">}</span></span></code></pre></figure></div><div role="tabpanel" data-nb-tabs-content data-nb-tab-label="wrangler.toml" class><figure class="nb-code-figure" data-nb-lang="toml"><pre class="astro-code astro-code-themes github-light github-dark nb-shiki-c6xiwz" tabindex="0" data-language="toml" data-nb-lang="toml"><code><span class="line"><span class="nb-shiki-140thh">[</span><span class="nb-shiki-1t8gfj">assets</span><span class="nb-shiki-140thh">]</span></span> <span class="line"><span class="nb-shiki-140thh">directory = </span><span class="nb-shiki-mdbnqw">"./dist"</span></span> <span class="line"><span class="nb-shiki-140thh">base_path = </span><span class="nb-shiki-mdbnqw">"/blog"</span></span></code></pre></figure></div></div></div><script type="module" src="https://developers.cloudflare.com/home/runner/work/cloudflare-docs/cloudflare-docs/src/components/ui/tabs/Tabs.astro?astro&type=script&index=0&lang.ts"></script></div><div data-nb-cli-variant="cf"><figure class="nb-code-figure nb-code-figure-titled" data-nb-lang="ts"><figcaption class="nb-code-title" data-pagefind-ignore=""><span class="nb-code-title-name">cloudflare.config.ts</span><span class="nb-code-title-lang">ts</span></figcaption><pre class="astro-code astro-code-themes github-light github-dark nb-shiki-c6xiwz" tabindex="0" data-language="ts" data-nb-lang="ts"><code><span class="line"><span class="nb-shiki-1itgoe">import</span><span class="nb-shiki-140thh"> { defineConfig } </span><span class="nb-shiki-1itgoe">from</span><span class="nb-shiki-mdbnqw"> "cf/config"</span><span class="nb-shiki-140thh">;</span></span> <span class="line"></span> <span class="line"><span class="nb-shiki-1itgoe">export</span><span class="nb-shiki-1itgoe"> default</span><span class="nb-shiki-1t8gfj"> defineConfig</span><span class="nb-shiki-140thh">({</span></span> <span class="line"><span class="nb-shiki-140thh">worker: {</span></span> <span class="line"><span class="nb-shiki-140thh"> name: </span><span class="nb-shiki-mdbnqw">"blog"</span><span class="nb-shiki-140thh">,</span></span> <span class="line"><span class="nb-shiki-21nrsd"> // Set this to today's date</span></span> <span class="line"><span class="nb-shiki-140thh"> compatibilityDate: </span><span class="nb-shiki-mdbnqw">"2026-10-28"</span><span class="nb-shiki-140thh">,</span></span> <span class="line"><span class="nb-shiki-140thh"> assets: {</span></span> <span class="line"><span class="nb-shiki-140thh"> basePath: </span><span class="nb-shiki-mdbnqw">"/blog"</span><span class="nb-shiki-140thh">,</span></span> <span class="line"><span class="nb-shiki-140thh"> },</span></span> <span class="line"><span class="nb-shiki-140thh">},</span></span> <span class="line"><span class="nb-shiki-140thh">});</span></span></code></pre></figure></div></div> <p>With Wrangler, <code>assets.directory</code> selects the directory to serve. With <a href="https://developers.cloudflare.com/cf/projects/cloudflare-config/"><code>cloudflare.config.ts</code></a>, your build configuration supplies the assets.</p> <p>To configure the option, refer to <a href="https://developers.cloudflare.com/workers/static-assets/routing/advanced/serving-a-subdirectory/">Serving a subdirectory</a>.</p>
The text above is the source's. reef added the severity, the dates it could read from the text, and the endpoints and scopes named in code.