Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 2.85 KB

File metadata and controls

26 lines (21 loc) · 2.85 KB

Deployment on Cloudflare Workers

  1. Fork the repository to your GitHub account.

  2. Create a KV namespace (under Storage & Databases -> KV), and copy the namespace ID.

  3. Update the kv_namespaces ID in wrangler.jsonc with your own namespace ID.

  4. (Optional) For OpenGraph image upload, create an R2 bucket named sink (or run wrangler r2 bucket create sink). If you don't need this feature, comment out the r2_buckets section in wrangler.jsonc.

  5. Create a project in Cloudflare Workers.

  6. Select the Sink repository and use the following build and deploy commands:

    • Build command: pnpm run build or npm run build
    • Deploy command: npx wrangler deploy
  7. Save and deploy the project.

  8. After deployment, go to Settings -> Variables and Secrets -> Add, and configure the following environment variables:

    • NUXT_SITE_TOKEN: Must be at least 8 characters long. This token grants access to your dashboard.
    • NUXT_CF_ACCOUNT_ID: Find your account ID.
    • NUXT_CF_API_TOKEN: Create a Cloudflare API token with at least Account.Account Analytics permission. See reference.
    • (Optional) NUXT_WEBHOOK_URL: The HTTPS endpoint that enables and receives click webhooks.
    • (Optional) NUXT_WEBHOOK_SECRET: A whsec_-prefixed Base64 secret. Generate one with printf 'whsec_%s\n' "$(openssl rand -base64 32)" and store it as a secret in the dashboard, not in wrangler.jsonc. If omitted, delivery is unauthenticated and unsigned, which is not recommended over untrusted networks.
  9. Enable Analytics Engine. In Workers & Pages, go to Account details in the right panel, locate Analytics Engine, and click Set up to enable the free tier. Name them sink and ANALYTICS, or else overwrite it with NUXT_DATASET and update your wrangler.jsonc accordingly

  10. Redeploy the project.

  11. To update your code, refer to the official GitHub documentation: Syncing a fork branch from the web UI.

To optionally protect the dashboard with Cloudflare Zero Trust while keeping short links public, refer to Cloudflare Access Authentication.

Click webhook delivery is best effort and has no retries. See Click Webhooks for payload, signature, and privacy details.