Serve Workers Static Assets from a Path Prefix like /blog/!
Hello, it's Shii-chan!
Cloudflare ChangelogWhen you want a static site under /blog/, reshuffling your build output folders is a bit of a chore. Today's update makes that easier!
What was announced?
The Cloudflare Changelog announced that Workers Static Assets can now serve assets from a URL path prefix, without changing the directory structure.
There are two places to set it:
- Wrangler:
assets.base_path cloudflare.config.ts:worker.assets.basePath
What changes
If you want to serve your build output under /blog/, you no longer need to move files into a blog folder. You just specify the prefix in config.
Dive Deep
Here are the required versions:
- Wrangler 4.148.0 or later
- cf 1.0.0-beta.13 or later if you use
cloudflare.config.ts
A Wrangler example (wrangler.jsonc):
{
"$schema": "./node_modules/wrangler/config-schema.json",
"assets": {
"directory": "./dist",
"base_path": "/blog"
}
}
In wrangler.toml:
[assets]
directory = "./dist"
base_path = "/blog"
And in cloudflare.config.ts:
import { defineConfig } from "cf/config";
export default defineConfig({
worker: {
name: "blog",
compatibilityDate: "2026-10-28",
assets: {
basePath: "/blog",
},
},
});
With Wrangler, assets.directory selects the directory to serve. With cloudflare.config.ts, your build configuration supplies the assets. The announcement doesn't spell out exactly how request paths map to files, so check the "Serving a subdirectory" docs for details!
Wrap-up
- Serve Workers Static Assets from a URL path prefix
- No directory structure changes needed
- Set
assets.base_pathin Wrangler orworker.assets.basePathincloudflare.config.ts - Requires Wrangler 4.148.0+ or cf 1.0.0-beta.13+
Great for anyone who wants to serve part of a site from a path like /blog on Workers!