Skip to content

Migrate to Cloudflare - #2432

Merged
matthewp merged 39 commits into
mainfrom
cloudflare-migration
Jun 12, 2026
Merged

Migrate to Cloudflare#2432
matthewp merged 39 commits into
mainfrom
cloudflare-migration

Conversation

@matthewp

@matthewp matthewp commented May 28, 2026

Copy link
Copy Markdown
Contributor

Migrate astro.build from Netlify to Cloudflare Workers.

DO NOT MERGE: There's a few moving parts here to deploy this.

@netlify

netlify Bot commented May 28, 2026

Copy link
Copy Markdown

Deploy Preview for astro-www-2 ready!

Name Link
🔨 Latest commit d13a2bd
🔍 Latest deploy log https://app.netlify.com/projects/astro-www-2/deploys/6a2c05af2922d40008fdafe4
😎 Deploy Preview https://deploy-preview-2432--astro-www-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 28, 2026

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://cloudflare-migration.previews.astro.build (commit d13a2bd)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://a3c553a2.previews.astro.build d13a2bd 2026-06-12T13:14:54.613Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://382d6697.previews.astro.build be90647 2026-06-11T21:04:59.546Z Visit the dashboard ↗
  • Build: Failed ❌

View logs ↗
59536a1 2026-06-11T20:58:41.488Z View logs ↗
  • Build: Failed ❌

View logs ↗
53fd01d 2026-06-11T20:54:34.366Z View logs ↗
  • Build: Failed ❌

View logs ↗
cbcea5f 2026-06-11T20:49:13.899Z View logs ↗
  • Build: In progress 🔵

View logs ↗
8ee6041 2026-06-11T20:47:46.243Z View logs ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://4f7b877c.previews.astro.build 1089ce1 2026-06-11T20:45:05.994Z Visit the dashboard ↗
  • Build: In progress 🔵

View logs ↗
0529168 2026-06-11T20:34:55.419Z View logs ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://4344687d.previews.astro.build 4aafcb8 2026-06-10T12:56:58.086Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://e2f723be.previews.astro.build f0edf23 2026-06-10T12:52:39.027Z Visit the dashboard ↗

View all previews: View all previews ↗

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 28, 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 successful!
View logs
astro-build d13a2bd Jun 12 2026, 01:14 PM

Comment thread src/app.ts Outdated

<video autoplay controls loop muted playsinline>
<source src="/assets/blog/launch-video.mp4" type="video/mp4" />
<source src="https://site-assets.astro.build/blog/launch-video.mp4" type="video/mp4" />

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This video exceeds the size allowed in Workers, so I pushed it to an R2 bucket and make this domain an alias to it.

Comment thread src/content.config.ts
['utilities', 'Utilities'],
['uncategorized', 'Uncategorized'],
] as const);
import { IntegrationCategories } from './data/integration-categories.js';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevents the content config from being imported into prod (where it breaks in workerd).

@matthewp matthewp mentioned this pull request May 29, 2026
Comment thread public/_redirects
@matthewp

matthewp commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

251286d#diff-841254fe75488c1bd4cd7f68f00b4be0e48dcfbc4a16b45847b68295e0e3b27bR8-R15

Moved the font proxying to inside of the worker. I see similar load times for the fonts.

Comment thread src/pages/agencies/index.astro Outdated
Comment on lines -15 to 19
export const prerender = false;
export const prerender = true;

if (Astro.url.searchParams.size > 0) {
Astro.redirect(`/themes/1/${Astro.url.searchParams.toString()}`, 301);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m realising the change to a static page will break the redirect.

Discussing on Discord whether we need to keep it or not: https://discord.com/channels/830184174198718474/1473314557593387100/1514206476212895795

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this back to SSR then: 4aafcb8

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK — we can monitor performance. Hopefully it’s fine and Cloudflare will catch up to Netlify’s capabilities soon.

Comment thread astro.config.mjs Outdated
Comment on lines +12 to +13
/* On Cloudflare Workers Builds, CF_PAGES_URL is set to the preview URL for non-production deploys */
const PREVIEW_SITE = process.env.CF_PAGES_URL;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is correct?

In the preview deploy I’m seeing everything using astro.build and not a preview-specific URL, e.g. og:image URLs etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use WORKERS_CI_BRANCH which seems to fix it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good — we should check after merging to make sure this is also the value we want in prod (i.e. it should be https://cloudflare-migration.previews.astro.build/ or whatever for previews, but https://astro.build/ for prod).

@delucis delucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like our patch which blocks animated images in the image service (patches/astro.patch) is no longer working, compare the first image on

It’s to the sharp image service, maybe Cloudflare uses a different one?

Also spotted something around redirects.

Other than that, there’s a lockfile conflict which will need resolving before merging.

Comment thread public/_redirects
@delucis

delucis commented Jun 11, 2026

Copy link
Copy Markdown
Member

Ah, re: the image service, @theotterlord pointed out that it could be because those images are on on-demand pages and so there’s no optimisation enabled at all by default on CF? On Netlify we do optimise on-demand images.

@matthewp

Copy link
Copy Markdown
Contributor Author

Ok, resolved most everything here:

  1. Redirects to non-trailing slash weren't working because in Cloudflare the file expects exact matches. Fixed by adding duplicates.
  2. Switched to cloudflare-binding to get on-demand optimizations as well. This doesn't fix the animation issue. I think it's supported by the image binding in Cloudflare, but I'll need to add an option to the adapter to allow that to be configured. Will have that in a future PR.

Removed the patch as well. We really shouldn't be patching Astro internals as workarounds. If Astro lacks a needed feature we should add it, and feel the pain like all of our users until it is.

Ready for another review.

@matthewp

Copy link
Copy Markdown
Contributor Author

Or wait, maybe not, build issue it seems.

@matthewp

Copy link
Copy Markdown
Contributor Author

Ok, ready now.

@delucis delucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good mostly!

Agree re: patching — it’s just an unusual need (“disallow animated images”) so it was hard to prioritise in Astro itself and this was a quick hack for what is fundamentally an issue in the theme portal (which we intentionally have not been investing time in). So yeah, limited resources => suboptimal solutions. But an image component option that disables animation could be handy for sure (<Image {src} alt="" noAnimation /> or whatever) — not sure if it would be supported in all target image services though.

Comment thread astro.config.mjs

@delucis delucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats @matthewp I believe you have slain the final boss!

Cloudflare sure doesn’t make things easy 😅

Left two final notes for us to bear in mind post-merge.

I’d also love to figure out the PR comments situation as the stuff CF posts is not amazing, but we can see what it looks like in real-world PRs first.

Comment thread astro.config.mjs
Comment on lines +12 to +15
/* On Cloudflare Workers Builds, WORKERS_CI_BRANCH is set to the branch name for non-production deploys */
const PREVIEW_SITE = process.env.WORKERS_CI_BRANCH
? `https://${process.env.WORKERS_CI_BRANCH}.previews.astro.build`
: undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder for us to double check this once the PR merges.

Comment thread astro.config.mjs
},
adapter: netlify({ imageCDN: false }),
adapter: cloudflare({
imageService: 'cloudflare-binding',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting that images feel noticeably slower in the preview deploy. I think this is because Netlify had a kind of hybrid set-up:

  • images on static pages are optimized at build time and served from the CDN
  • images on dynamic pages are optimized on demand

But with cloudflare-binding all images are served on-demand.

Not a blocker necessarily, but worth looking into improving. I know @OliverSpeir had one suggestion in withastro/astro#15662 and there’s also withastro/astro#16194 which is related.

@matthewp

Copy link
Copy Markdown
Contributor Author

Merging, will check all of these things after DNS is updated.

@matthewp
matthewp merged commit 4012c2e into main Jun 12, 2026
8 checks passed
@matthewp
matthewp deleted the cloudflare-migration branch June 12, 2026 17:06
matthewp added a commit that referenced this pull request Jul 13, 2026
matthewp added a commit that referenced this pull request Jul 13, 2026
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.

3 participants