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 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();
})
Was this page helpful?