Skip to content

Add geo-localized pricing via bunny.net edge script - #10

Merged
taobojlen merged 3 commits into
mainfrom
geo-localized-pricing
Jul 24, 2026
Merged

Add geo-localized pricing via bunny.net edge script#10
taobojlen merged 3 commits into
mainfrom
geo-localized-pricing

Conversation

@taobojlen

@taobojlen taobojlen commented Jul 24, 2026

Copy link
Copy Markdown
Member

No description provided.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
shroud-email-website 6c94443 Jul 24 2026, 02:26 PM

@taobojlen
taobojlen force-pushed the geo-localized-pricing branch 3 times, most recently from 45ca90f to 993473b Compare July 24, 2026 15:30
@taobojlen taobojlen changed the title Add geo-localized pricing (£25 UK / 5 worldwide) via bunny.net edge script Add geo-localized pricing markers to pricing page (website half) Jul 24, 2026
@taobojlen
taobojlen force-pushed the geo-localized-pricing branch from 993473b to f84f9f5 Compare July 24, 2026 15:34
@taobojlen taobojlen changed the title Add geo-localized pricing markers to pricing page (website half) Add geo-localized pricing (£25 UK / 5 worldwide) via bunny.net edge script Jul 24, 2026
Show £25/year to UK visitors and $35/year to everyone else, dynamically based
on the visitor's country, rewritten at the bunny.net edge.

Website changes:
- Pricing.vue: hero heading + price table cell show a single £25/year default,
  wrapped in <span data-price=""> markers (the edge script's rewrite targets).
- pricing.astro: drop client:load on the Pricing component. It is purely
  presentational, so static rendering avoids a hydration snap-back that would
  overwrite the edge-rewritten price. Also ships no JS for the page.
- tsconfig.json: exclude edge-script/ from astro check (it has its own Deno
  type-check; the bundled output was producing spurious TS errors).

Edge script (edge-script/):
- Middleware using servePullZone + HTMLRewriter. Non-UK visitors get
  $35/year; UK/unknown visitors see the £25/year default baked into the HTML
  (safe degradation if the script is disabled or the country header is missing).
- Sets Cache-Control: no-store on HTML responses so the per-visitor rewrite
  isn't cached and served to a visitor in the other region. Static assets keep
  their original cache headers.
- Bundled to a single file via esbuild + @luca/esbuild-deno-loader (mirrors
  the official BunnyWay template).

Deploy: handled by the combined "Deploy to staging" workflow on main (PR #14),
which deploys both the site and the edge script in one run.
@taobojlen
taobojlen force-pushed the geo-localized-pricing branch from 768613d to eac1437 Compare July 24, 2026 16:09
The free-plan price was hardcoded £0 with no data-price marker, so US visitors
saw '£0' in the table while the paid price localized. Now every price element
(hero, free cell, paid cell) carries data-price-world with its worldwide value,
and the edge script swaps in that value for non-UK visitors.

- Pricing.vue: add freeWorld/paidWorld to the Price row; mark the free cell
  with data-price + data-price-world just like the paid cell.
- edge-script/pricing.ts: select on [data-price-world] and set the content to
  the attribute's value, instead of hardcoding a single $35/year replacement.
  Now handles £0->$0 and £25/year->$35/year independently.
Extend the prod deploy workflow (deploy.yml) with a parallel deploy-edge-script
job, mirroring staging. On push to main it now deploys both the site and the
edge script using prod secrets (BUNNY_SCRIPT_ID / BUNNY_DEPLOY_KEY).

So merging PR #10 deploys the geo-localized pricing to prod automatically, once
those prod secrets + a prod edge script (attached to the production pull zone)
are configured.
@taobojlen taobojlen changed the title Add geo-localized pricing (£25 UK / 5 worldwide) via bunny.net edge script Add geo-localized pricing via bunny.net edge script Jul 24, 2026
@taobojlen
taobojlen merged commit 16eb9ee into main Jul 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant