cloudflare workers
local dev
Local Storage Location
When you run the command wrangler dev
, any data related to R2, as well as other resources, is saved in the .wrangler/state
directory within your project folder. This directory is automatically created if it doesn’t exist. The files uploaded during local development are stored in a subdirectory under .wrangler/state
, specifically in a path like .wrangler/state/../r2/Blob
Customizing Storage Location
you can use the --persist-to
flag with the wrangler dev
command. This allows you to specify a different directory for local storage, which can help in organizing your project or separating local development data from other files
Running in compose
mapping state dir to local machine
... cloudflare-worker: build: dockerfile: ../cloudflare.dockerfile volumes: - /tmp/cloudflare/worker:/app/.wrangler/state ports: - "8787:8787" environment: - NODE_ENV=development command: wrangler dev --port 8787 --ip 0.0.0.0...
cloudflare worker jwt auth with hono
import { Hono } from 'hono';import { verify } from 'hono/jwt';import { bearerAuth } from 'hono/bearer-auth';
...app.use( '*', bearerAuth({ verifyToken: async (token, c) => { return !!verify(token, c.env.JWT_SECRET); }, }),);...