When visiting my cloudflare worker: `cfworker No fetch handler attached.
See original GitHub issueUnfortunately when visiting the cloudflare worker URL provided by the browser page which automatically opens, I got a html page with No fetch handler attached.
. I’m not sure how to fix it.
To run this, I used: webpack --watch & cfworker run worker.js -p 14000 --watch --inspect
.
I have the code in this branch of the repo, the index.js is here. I am simply doing:
addEventListener('fetch', (event) => { const url = new URL(event.request.url)
const fetchEvent = event as FetchEvent; fetchEvent.respondWith(new Response("HELLO there"))
return
}
})
Note: it works when running without cfworker: webpack && wrangler preview --env test
Thank you for your time and help 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
FetchEvent · Cloudflare Workers docs
If no fetch event handler calls respondWith , then the runtime forwards the request to the origin as if the Worker did not....
Read more >HTMLRewriter · Cloudflare Workers docs
The HTMLRewriter class should be instantiated once in your Workers script, with a number of handlers attached using the on and onDocument ...
Read more >Fetch · Cloudflare Workers docs
Asynchronous tasks such as fetch are not executed at the top level in a Worker script and must be executed within a FetchEvent...
Read more >KV · Cloudflare Workers docs
Documentation for Cloudflare Workers, a serverless execution environment that allows you to create entirely new applications or augment ...
Read more >Limits · Cloudflare Workers docs
Bundled Workers limits are based on CPU time, rather than duration. This means that the time limit does not include the time a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks a lot @jdanyow, that fixed it 😃
@ben-xD I think the command should be something like:
Based on your webpack config: https://github.com/ben-xD/ably-cloudflare-workers/blob/main/webpack.config.js#L9-L12
You’d need to check your dist folder to find the correct filename to pass to cfworker run.