© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•12mo ago•
8 replies
theo

update request url with workers static assets

seems like this should be simple, but I can't find any examples. Say I'm using workers static assets, and I have enabled run_worker_first. It seems that
env.ASSETS.fetch
env.ASSETS.fetch
wants the incoming request passed through - but what if I want to change which file gets fetched?

// (example using hono)
app.use('/*', async (c, next) => {
  const url = new URL(c.req.url);
  const urlPath = url.pathname;
  if (urlPath === '/a) {
    // i want to return a different file
    return c.env.ASSETS.fetch('/b.html');
  }
  return next();
})
// (example using hono)
app.use('/*', async (c, next) => {
  const url = new URL(c.req.url);
  const urlPath = url.pathname;
  if (urlPath === '/a) {
    // i want to return a different file
    return c.env.ASSETS.fetch('/b.html');
  }
  return next();
})
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to update Workers Static Assets?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
12mo ago
Workers with static assets - asset caching?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
14mo ago
Static Assets Support in Workers
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
10mo ago
How to cache workers with static assets (beta)?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
14mo ago