Not working on cloudflare worker
See original GitHub issueHi,
Cloudflare worker provides a fetch function, however, when I’m webpacking your lib, it does seem to use XMLHttpRequest
ReferenceError: XMLHttpRequest is not defined
I did try to force webpack to use node
module.exports = {
target: "webworker",
entry: "./worker.js", // inferred from "main" in package.json
resolve: {
mainFields: ['module', 'main']
}
};
But it generates another error (global not defined)
Is there a way to force cross-fetch to to use the native fetch function?
as a proof of concept/fugly workaround, I replaced
const Fetch = fetch; //require('cross-fetch');
and it seems to work fine.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:8
Top Results From Across the Web
Worker not running - Cloudflare Community
I have created a worker for my website but it is not working in all cases. The DNS I have set contains 2...
Read more >Known issues · Cloudflare Workers docs
Known issues. Below are some known bugs and issues to be aware of when using Cloudflare Workers. Route specificity.
Read more >Worker not working when enabled for a specific route
My worker should retrieve content from a different page and it's not doing it. It means the routes I set are not working....
Read more >Worker route not working - Cloudflare Community
Hello! I have a problem with Worker, namely I want to add response header for specific domains, I configured such routes: *example.com/*, ...
Read more >Routes not working for worker - Cloudflare Community
Hi, I have deployed two workers with routes and query parameters in the URL through the wrangler GitHub Action. One has been successful...
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
The link is 404’ing since the dist folder that I was referencing was deleted along with all the other dist files at the beginning of the year.
It looks like that was also how browser fetch was supported so I am unsure what @lquixada’s plan was as the owner and maintainer of the repo.
👀 https://github.com/lquixada/cross-fetch/blob/main/dist/browser-ponyfill.js#L546
Uncommenting that line and commenting out the one below fixed my issue