Marcelino Franchini
11/27/2021, 1:50 AMThe Freelancer ;)
11/27/2021, 1:50 AMReaverCelty
11/27/2021, 4:43 AMErwin
11/27/2021, 4:47 AMReaverCelty
11/27/2021, 4:53 AMWalshy | Pages
11/27/2021, 5:02 AMReaverCelty
11/27/2021, 5:04 AMErwin
11/27/2021, 5:20 AMErwin
11/27/2021, 5:38 AMnpx wrangler@beta pages dev
and then specify the build directoryMarcelino Franchini
11/27/2021, 2:39 PMMarcelino Franchini
11/27/2021, 2:40 PMWalshy | Pages
11/27/2021, 2:40 PMWalshy | Pages
11/27/2021, 2:41 PMReaverCelty
11/27/2021, 6:05 PMTim
11/28/2021, 1:29 AMjohanndev
11/28/2021, 10:48 AMrkusa
11/28/2021, 12:42 PMrkusa
11/28/2021, 3:27 PMwaitUntil
inside of pages functions is broken? I am receiving a Illegal invocation
both in miniflare and deployed. Looking at miniflare's code made me beliefe that I shouldn't deconstruct the context (onRequest({ctx})
), but I get the same error with ctx.waitUntil
.Vinsg
11/28/2021, 4:40 PMServing at http://127.0.0.1:[[your port]]
from the console output.johanndev
11/28/2021, 4:55 PM--port
switch is not optional - when I provide a proxy-port, everything works as expected:
npx wrangler@beta pages dev --proxy 3000 --local ./static
simplenotezy
11/28/2021, 8:02 PMrkusa
11/28/2021, 8:42 PMjson
"build:version": "echo \"{ \\\"rev\\\": \\\"${CF_PAGES_COMMIT_SHA:=dev}\\\" }\" > worker/version.json",
and import it in my worker/function via
ts
import version from "../worker/version.json";
// version.rev gives you CF_PAGES_COMMIT_SHA
simplenotezy
11/28/2021, 8:47 PMfx.writeFile
to write the version number to a file.simplenotezy
11/28/2021, 8:47 PMjohanndev
11/28/2021, 9:07 PMexport async function onRequestGet(context) {
return new Response("Hello from <path/to/worker>");
}
and tried to call these paths:
http://localhost:8788/api/todos
http://localhost:8788/api/todos/1
http://localhost:8788/api/todos/1/edit
http://localhost:8788/foo/profile
http://localhost:8788/api/my/custom/path
All of these paths return the index.html page from my vue app and don't invoke the respective worker.
If I however place an index.ts
with the same code at ./functions/index.ts
, the route http://localhost:8788
works and returns the expected response!
What am I missing ? :/
Opened an issue on github: https://github.com/cloudflare/wrangler2/issues/58Jeremiahlee
11/28/2021, 9:22 PMaddEventListener("fetch", (event) => {
event.passThroughOnException();
event.respondWith(handleRequest(event));
});
in a Pages Function, but I get this error:
Global addEventListener() cannot be used in modules. Instead, event handlers should be declared as exports on the root module.
and I don't know what to do with that.
Any pointers?Walshy | Pages
11/28/2021, 9:23 PMjs
export async function onRequest(context) {
return new Response("Hello, world!");
}
Jeremiahlee
11/28/2021, 9:24 PMfetch
for when my function makes a fetch
request, not the request triggering the function.Walshy | Pages
11/28/2021, 9:26 PMJeremiahlee
11/28/2021, 9:27 PM