Erisa | Support Engineer
12/10/2021, 5:25 PM_worker.js
will run on any request, with the idea being that you add your own routing or custom logic instead of relying on the built-in onesaibotsivad
12/10/2021, 8:16 PM_worker.js
override all requests? aka how does one serve static assets from Pages?saibotsivad
12/10/2021, 8:16 PMreturn env.ASSETS.fetch(request)
snippet on the docs page, is ASSETS
a special env
pass-through to the static assets?saibotsivad
12/10/2021, 8:17 PMWalshy | Pages
12/10/2021, 8:17 PMenv.ASSETS.fetch
is the way to gosaibotsivad
12/10/2021, 8:21 PMcontext
object https://developers.cloudflare.com/pages/platform/functions#writing-your-first-function
env, // same as existing Worker API
but I'm having a hard time finding where env
is documented in the Worker APIsaibotsivad
12/10/2021, 8:22 PMsaibotsivad
12/10/2021, 8:23 PMsaibotsivad
12/10/2021, 8:24 PMASSETS
coming from? something special to Pages?Walshy | Pages
12/10/2021, 8:25 PMWalshy | Pages
12/10/2021, 8:26 PMenv
Walshy | Pages
12/10/2021, 8:26 PMsaibotsivad
12/10/2021, 9:08 PMenv
is "documented" is in the "Writing your first function" code snippet, where the comment says it's "same as existing Worker API"saibotsivad
12/10/2021, 9:12 PMenv
, and I can't find where it's mentioned, so effectively env
is entirely undocumented at this point)HardAtWork
12/10/2021, 9:25 PMenv
basically has type: any
, as the structure of env
is defined by the User. The only time(that I can think of off the top of my head), where env
has a predefined child is in Pages, as you mentioned, with env.ASSETS
.maxbeyer
12/11/2021, 6:21 AMCould not resolve "fs" (use "platform: 'node'" when building for node)
. I tried playing with the default webpack config, but couldnt get it to work. Do you have any hints, on how to solve this issue?HardAtWork
12/11/2021, 6:26 AMErwin
12/11/2021, 8:24 AMthreepointone
12/11/2021, 8:25 AMthreepointone
12/11/2021, 8:26 AMmaxbeyer
12/11/2021, 11:40 AMmaxbeyer
12/11/2021, 11:42 AMsaibotsivad
12/11/2021, 9:55 PMsaibotsivad
12/11/2021, 9:57 PM/functions/api/messages/send.js
than you'd need something like /src/send-message.js
and have Webpack build the output to /functions/api/messages/send.js
as part of the build, then Pages will deploy your built scriptsaibotsivad
12/11/2021, 9:57 PMKeenwau
12/11/2021, 10:08 PMsaibotsivad
12/11/2021, 10:11 PMsaibotsivad
12/11/2021, 10:13 PMsaibotsivad
12/11/2021, 10:14 PM