Kieran Huggins
02/21/2022, 2:11 AMenv.ASSETS
?
This is what I ended up with btw
export async function onRequest({env, request: {cf: {country, regionCode}, url}}) {
let filename = `${country}_${regionCode}.json`.toLowerCase();
return await env.ASSETS.fetch(`${url}/${filename}`);
}
Larry
02/21/2022, 3:08 AMKieran Huggins
02/21/2022, 10:43 AMGreg Brimble | Cloudflare Pages
02/21/2022, 2:57 PMts
export async function onRequest({env, request, url}) {
const {cf: {country, regionCode} = request
let filename = `${country}_${regionCode}.json`.toLowerCase();
return await env.ASSETS.fetch(`${url}/${filename}`, request);
}
Greg Brimble | Cloudflare Pages
02/21/2022, 2:58 PMRaifY
02/21/2022, 2:59 PMRaifY
02/21/2022, 3:00 PMzsmooth
02/22/2022, 4:15 AM_worker.js
to your output dir instead of having `functions`: https://developers.cloudflare.com/pages/platform/functions#advanced-modeBroonix
02/22/2022, 8:57 PMHTMLRewriter
I'm getting errors that the content is not streamable. I'm loading the content via env.ASSETS.fetch(request)
HardAtWork
02/22/2022, 9:09 PMjs
return new HTMLRewriter().on("div", new ElementHandler()).transform(await env.ASSETS.fetch(req));
Broonix
02/22/2022, 9:17 PMHardAtWork
02/22/2022, 9:20 PMawait env.ASSETS.fetch(req)
?Walshy | Pages
02/22/2022, 9:22 PMWalshy | Pages
02/22/2022, 9:22 PMBroonix
02/22/2022, 9:23 PMBroonix
02/22/2022, 9:25 PMErwin
02/23/2022, 1:10 AMDeleted User
02/23/2022, 4:43 PMcontext
argument documented and is env.ASSETS
inherent to all pages projects? I assume this is baked-in equivalent of using the kv asset handler in Workers Sites.Deleted User
02/23/2022, 4:50 PMGreg Brimble | Cloudflare Pages
02/23/2022, 5:22 PMenv.ASSETS.fetch()
is available to all Pages projects using Functions 🙂Deleted User
02/23/2022, 5:23 PMvivekpatt_whyd
02/23/2022, 7:45 PMmibaatwork
02/23/2022, 7:46 PMIsaac McFadyen | YYZ01
02/23/2022, 7:46 PM/functions/en/index.js
for English,
/functions/fr/index.js
for French,
etc.Isaac McFadyen | YYZ01
02/23/2022, 7:47 PMdist
, it needs to be in the root of your project.Isaac McFadyen | YYZ01
02/23/2022, 7:47 PMadapter-auto
or adapter-cloudflare
.Isaac McFadyen | YYZ01
02/23/2022, 7:47 PMmibaatwork
02/23/2022, 7:48 PMmibaatwork
02/23/2022, 7:51 PMIsaac McFadyen | YYZ01
02/23/2022, 7:52 PM/src/routes/api/index.js