Cloudflare with Astro
Most of an Astro site is files, and files are what a CDN is for. Cloudflare serves them from wherever the visitor is, and the interesting part of the setup is the small list of things that are not files: the redirects a migration leaves behind, the headers, and any route that has to do work when it is asked rather than when it is built.
Cloudflare integrations like this usually take 2–4 days
How the handoff works.
- 01
Build
Pages rendered before anyone asks
- 02
Rules
Redirects and headers generated with them
Key handoff
- 03
Upload
Assets pushed to the edge
- 04
Serve
Delivered from near the visitor
- 05
Verify
Every redirect requested, not sampled
Why this is the key handoff
Built once, served everywhere. The build produces files and a redirect list. Cloudflare serves the first from the edge and applies the second before anything else is looked up, which is why a migration's redirects belong in the host rather than in the site.
Three things that commonly go wrong.
- 01
Redirect order is not alphabetical, and it matters
A wildcard placed above a specific rule makes that rule unreachable, and nothing warns you: the specific address quietly lands wherever the wildcard points. After a migration this is the failure that sends the six most valuable old URLs to the home page. The list is generated in a deliberate order and then requested, not read.
- 02
Not everything an Astro site can do survives on a static host
Anything wanting a server at request time needs a Worker, and Workers do not offer the whole Node API. A route that works locally can fail on deploy for the want of one module, so which routes need a request is a decision made before the build, not discovered after it.
- 03
Scheduled work is the thing people forget
A static site publishes what it was built with, so a post dated tomorrow appears when something rebuilds. On a host without a scheduler, that something is a person. Worth deciding up front whether a daily rebuild is automated or somebody's job.
What is included.
-
The built site served as static assets from the edge
-
Redirects from the migration, in the host's own format
-
Security and caching headers set per path
-
Routes that must run per request, where any exist
-
A custom domain, with the apex and www agreeing
Wire up something else?
-
Vercel with Astro
Hosting · typically 2–4 days
Learn more → -
Google Analytics with Astro
Analytics · typically 2–4 days
Learn more → -
Salesforce with Astro
CRM · typically 3–5 days
Learn more → -
HubSpot with Astro
CRM · typically 2–4 days
Learn more → -
Stripe with Astro
Payments · typically 1–2 weeks
Learn more → -
Segment with Astro
Data · typically 3–6 days
Learn more →
Reach out and see if we are a good fit.
Currently booking two to four weeks out.