Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
cloudflare-worker-local
Advanced tools
Run (or test) a Cloudflare Worker Locally. If you are looking for a project that will quickly help you bootstrap your worker, take a look at create-cloudflare-worker
$ npm install -g cloudflare-worker-local
$ cloudflare-worker-local /path/to/worker.js localhost:3000 4000
Listening on Port 4000 and forwarding requests to http://localhost:3000/
It is possible to use nodemon to automatically reload the worker
$ npm install -g nodemon
$ nodemon --watch /path/to/worker.js --signal SIGHUP --exec 'cloudflare-worker-local /path/to/worker.js localhost:3000 4000'
cloudflare-worker-local
can be used to unit test a cloudflare worker. Please see This Example. You may also be interested in create-cloudflare-worker
CF-IPCountry
header value from COUNTRY
environment variable (default is DEV
)To enable Minio as the KV store simply provide these options as environment variables: MINIO_ENDPOINT, MINIO_ACCESS_KEY, and MINIO_SECRET_KEY
$ MINIO_ENDPOINT="localhost" MINIO_ACCESS_KEY="my_access_key" MINIO_SECRET_KEY="my_secret" cloudflare-worker-local /path/to/worker.js localhost:3000 4000
Optionally, these variables are available as well: MINIO_PORT, MINIO_USE_SSL, MINIO_REGION, MINIO_TRANSPORT, MINIO_SESSIONTOKEN, and MINIO_PARTSIZE
See the Minio documentation for details on the various parameters.
To use the File System as the KV store simply provide the KV_FILE_ROOT option as an environment variable. A directory will be created in here for each KV namespace.
Support for CloudFlare Environment Variables and Secrets is provided via a wrangler.toml file. See the wrangler documentation for more information on the file schema.
To load the wrangler.toml, specify it on the command line:
$ cloudflare-worker-local /path/to/worker.js localhost:3000 4000 /path/to/wrangler.toml
Optionally, the desired environment specified within the wrangler.toml can be loaded:
$ cloudflare-worker-local /path/to/worker.js localhost:3000 4000 /path/to/wrangler.toml production
Secrets are specified under the 'secrets' root key in the document. See the wrangler.toml for an example of the supported structures.
Two features are provided while loading the wrangler.toml:
Additionally, any 'kv-namespaces' in the wrangler.toml will be appended to the list of namespaces provided by KV_NAMESPACES.
If a wrangler.toml file containing a [site]
section with a bucket
directory is loaded, the Workers Sites
default KV namespace and manifest will be added to the worker's scope. Calls to getAssetFromKV
will always
return the latest version of an asset in the bucket
directory. Note that you'll need to bundle your worker
code (with Webpack for instance) before running it to use @cloudflare/kv-asset-handler
, as import
/
require
are not in workers' scopes.
FAQs
Run a Cloudflare-compatible Worker Locally
We found that cloudflare-worker-local demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.