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();
})
// (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();
})
2 Replies
Walshy
Walshy5d ago
env.ASSETS.fetch('https://assets.local/b.html);
theo
theoOP5d ago
ok great - I figured there must be an easy way, but could not find anything in the docs or examples anywhere

Did you find this page helpful?