Skip to content

POC Cloudflare Worker using web-sys

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE_APACHE
MIT
LICENSE_MIT
Notifications You must be signed in to change notification settings

SvenJanssens/cf-worker-poc-websys

A proof-of-concept for using web-sys-fetch in a Cloudflare Worker

This proof-of-concept takes the web-sys/fetch example at the wasm-bindgen website and adapts it so it can be used as a Cloudflare worker.

To generate the required files for a Cloudflare worker, the excellent template for kick starting a Cloudflare worker project using wasm-pack was used.

Findings

  • The example at the wasm-bindgen website uses the websys::window() function to send out the request to the API. However, websys::Window context is not usable in a Cloudflare Worker (as there is no window). In this case the websys::Worker context should be used.
  • The GitHub API now requires for the calling logic to send a HTTP Header "UserAgent".
  • opts.mode(RequestMode::Cors); >>> This line had to be removed, because the mode setting of the request is not implemented by CloudFlare.

About

POC Cloudflare Worker using web-sys

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE_APACHE
MIT
LICENSE_MIT

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published