Skip to content

Initial Setup Guide - Cloudflare Workers

Note: This guide is for first-time setup of Cloudflare Workers. For current deployment workflows, see Cloudflare.

Prerequisites

  • Cloudflare account with Workers access
  • nutrieapp.com domain added to Cloudflare
  • Wrangler CLI installed (npm install -g wrangler)
  • OpenAI API key

Step 1: Set Up KV Namespaces

Create required KV namespaces for rate limiting and subscriptions.

Via Cloudflare Dashboard

  1. Go to https://dash.cloudflare.com
  2. Select your account -> Workers & Pages -> KV
  3. Create namespaces: RATE_LIMIT, SUBSCRIPTIONS

Via CLI

cd cloudflare-worker
wrangler kv:namespace create "RATE_LIMIT"
wrangler kv:namespace create "SUBSCRIPTIONS"

Update wrangler.toml with the namespace IDs.

Step 2: Configure Secrets

cd cloudflare-worker
wrangler secret put OPENAI_API_KEY
wrangler secret put DEVICE_SALT

Step 3: Deploy Workers

See Cloudflare for deployment instructions.

Step 4: Configure App Store Connect

See Subscriptions for webhook URL configuration.