How this static site (Eleventy → Cloudflare Pages) connects to AmentCase,
the firm's practice-management platform (Flask → Railway). Read this before
touching any form, the chat widget, the scheduler, or functions/api/*.
Companion doc on the server side:
INTEGRATION.mdin the AmentCase repo, which documents what each endpoint does with the data it receives.
| Boundary | Code | Used for |
|---|---|---|
| Cloudflare Worker functions | functions/api/*.js |
AI chat proxy, newsletter, county-data proxies, the assessment-appeal email report. Run at the edge; some also forward a lead to AmentCase. |
| Direct calls to AmentCase | inline fetch() in .njk pages |
Every real lead, booking, and referral. |
Every direct call uses https://amentcase.com, defined once in
_data/site.json:
{ "amentcase": "https://amentcase.com" }
To point the site at a different AmentCase host (e.g. app.amentcase.com or a
staging instance), change that one value and rebuild. Do not hardcode
https://amentcase.com in templates again — grep -rn "amentcase.com" --include=*.njk
should only ever match nothing (the value comes from site.amentcase).
Heads-up: the Cloudflare functions that call AmentCase (
chat-lead.js,appeal-report.js,newsletter-subscribe.js) are not templated by Eleventy, so they read the host fromenv.AMENTCASE_URL(set in Cloudflare → Pages → Environment variables), falling back tohttps://amentcase.com. To move the AmentCase host, changesite.amentcasehere and setAMENTCASE_URLin the Pages environment — no function code edit needed.
| Surface | Endpoint (via https://amentcase.com) |
Key payload fields |
|---|---|---|
7 intake forms (intake/*.njk) |
/api/website-lead |
first_name, last_name, email, phone, matter_type, message (message = ONLINE INTAKE FORM blob → server creates a matter immediately) |
contact.njk |
/api/website-lead |
+ source, referral handling for family-law/PI |
schedule.njk (callback / message) |
/api/website-lead |
matter_type, county, referral_source, source=contact_form |
schedule.njk (online booking, RE & business only) |
/api/scheduling/availability, /lead, /book |
{ lead, slot } |
refer.njk |
/api/website-referral, /api/website-referral/resend-link |
referrer + referred-client fields |
resources.njk, _includes/partials/resource-gate.njk |
/api/resource-download and /api/website-lead |
first_name, email, resource |
tools/*/index.njk (7 tools) |
/api/tool-lead |
first_name, email, tool |
client-portal.njk |
static link to https://amentcase.com/ |
— |
chat widget (_includes/layouts/base.njk) |
/api/chat, /api/chat-lead (Cloudflare, not AmentCase) |
see §3 |
| newsletter footer | /api/newsletter-subscribe (Cloudflare) |
email |
matter_type slugs must match AmentCase's MATTER_TYPE_MAP (see the server doc).
Unknown slugs silently become general. Personal-injury matters are referred out
(the injury intake sends personal-injury to stay consistent with contact.njk).
functions/api/)These run at the edge and hold the secrets. Configure env vars in Cloudflare → Pages → ament-law-website → Settings → Environment variables.
| Function | Calls | Secrets / bindings |
|---|---|---|
chat.js |
Anthropic API (claude-haiku-4-5) |
ANTHROPIC_API_KEY |
chat-lead.js |
Resend + amentcase.com/api/website-lead |
RESEND_API_KEY, FIRM_EMAIL, EMAIL_FROM |
newsletter-subscribe.js / -send.js / -subscribers.js / -unsubscribe.js |
Resend + KV NEWSLETTER + AmentCase (subscribe and unsubscribe forward to the CRM so its list stays in sync; subscribe sends notify:false) |
RESEND_API_KEY, EMAIL_FROM, AMENTCASE_URL; admin endpoints need a GitHub token |
appeal-report.js |
Resend + amentcase.com/api/website-lead |
RESEND_API_KEY, FIRM_EMAIL, EMAIL_FROM |
millage.js |
Allegheny County millage table (proxy, 24h cache) | — |
wprdc.js |
WPRDC datastore (comps, proxy) | — |
email-test.js |
Resend (diagnostic) | RESEND_API_KEY |
The chat widget allowlists origins inside chat.js / chat-lead.js
(www.ament.law, ament.law, ament-law-website.pages.dev, localhost).
AmentCase only accepts cross-origin form posts from an allowlist. Both the edge
functions and AmentCase allow the production origins and any
*.ament-law-website.pages.dev preview (suffix match), so forms work on every
Cloudflare Pages deploy — production-preview and per-branch previews — not just
www. Only a wholly different hostname (a custom staging domain) needs to be
added explicitly:
allowedOrigins arrays (for chat/newsletter).WEBSITE_EXTRA_ORIGINS env var
(no server code change needed) — or it will 403 on every lead/booking/referral._data/site.json, the two Cloudflare functions
that hardcode the host, and the AmentCase allowlist must move together.npx @11ty/eleventy and
grep -r "https://amentcase.com" _site/ — there should be no literal
template strings left in the built HTML (they should all be resolved URLs).Last reconciled against both repos during the website ⇄ AmentCase integration pass.