Configuration & Deployment
Environment secrets, Wrangler config, Sentry, and the auto-deploy flow for the ShipHero Handler worker.
The worker is a standard Cloudflare Workers project managed with Wrangler. This page covers its secrets, its config, and how it ships.
Environment variables
All values are stored as Cloudflare Worker secrets and read from c.env at
runtime. The worker itself does not use a .env file.
| Secret | Purpose |
|---|---|
SUPABASE_URL | Supabase project URL |
SUPABASE_KEY | Supabase API key |
SHIPHERO_SKU_RETRIEVAL_URL | n8n webhook used for the SKU fallback lookup |
SENTRY_DSN | Sentry error-tracking DSN |
ZONE_CALC_API_KEY | API key for the National Commerce zone calculator |
VERIFY_QUANTITIES | Optional. Set to "false" to disable quantity verification |
Add or update a secret with Wrangler:
npx wrangler secret put SECRET_NAMEBackfill scripts use a different key
The standalone backfill scripts
run outside the worker and read a local .env file with
SUPABASE_SERVICE_ROLE_KEY (the elevated service-role key), not the worker's
SUPABASE_KEY.
Wrangler config
wrangler.jsonc defines the worker:
name:shiphero-handlermain:src/index.tscompatibility_date:2025-04-08compatibility_flags:nodejs_compatobservabilityis enabled, withhead_sampling_rate: 1(100% of requests are traced)
TypeScript runs in strict mode and uses Hono's JSX runtime
(jsxImportSource: "hono/jsx").
Error tracking
The entire Hono app is wrapped with Sentry.withSentry. The Sentry config sets
sendDefaultPii: true (request headers and IP are attached) and
tracesSampleRate: 1.0. Uncaught errors in the handler surface in Sentry as
well as in the Cloudflare logs.
Local development
npm install
npm run dev # wrangler devnpm run dev starts the worker locally with Wrangler. There is no test
suite. Changes are verified by replaying webhooks against a running worker.
Deployment
Do not deploy manually
The repository is connected to Cloudflare through the GitHub integration.
Pushing commits triggers an automatic deploy. Do not run
npm run deploy / wrangler deploy by hand.
To ship a change: commit, push, and let Cloudflare deploy the latest commit.
Regenerating Supabase types
When the database schema changes, regenerate src/utils/supabase/types.ts:
npx supabase gen types typescript --project-id axzbddunsdtgjpnycprb > src/utils/supabase/types.tsThe generated file carries every table, enum, and relationship the worker needs for type-safe queries.
Supabase tables the worker touches
| Table | Role |
|---|---|
Brands | Holds the ShipHero access token; keyed by n8n_id |
Warehouses | Looked up by Warehouse_ID; supplies the warehouse ZIP |
Orders | Order records with financial fields |
Shipments | Shipment tracking, box, and zone data |
Shipment Line Items | Individual items within a shipment |
Product SKUs | Product SKU catalog |
End Customer (Amazon buyer) | Customer records from shipping addresses |
Stores | Store / shop records created from shop_name |