Migrate to Cloudflare - #2432
Conversation
✅ Deploy Preview for astro-www-2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://cloudflare-migration.previews.astro.build (commit d13a2bd)This URL reflects your latest Preview deploymentPreview Deployments by commit
View all previews: View all previews ↗ |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
astro-build | d13a2bd | Jun 12 2026, 01:14 PM |
…ob loader at runtime
…es, remove debug logging
|
|
||
| <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" /> |
There was a problem hiding this comment.
This video exceeds the size allowed in Workers, so I pushed it to an R2 bucket and make this domain an alias to it.
| ['utilities', 'Utilities'], | ||
| ['uncategorized', 'Uncategorized'], | ||
| ] as const); | ||
| import { IntegrationCategories } from './data/integration-categories.js'; |
There was a problem hiding this comment.
This prevents the content config from being imported into prod (where it breaks in workerd).
|
251286d#diff-841254fe75488c1bd4cd7f68f00b4be0e48dcfbc4a16b45847b68295e0e3b27bR8-R15 Moved the font proxying to inside of the worker. I see similar load times for the fonts. |
| export const prerender = false; | ||
| export const prerender = true; | ||
|
|
||
| if (Astro.url.searchParams.size > 0) { | ||
| Astro.redirect(`/themes/1/${Astro.url.searchParams.toString()}`, 301); | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
OK — we can monitor performance. Hopefully it’s fine and Cloudflare will catch up to Netlify’s capabilities soon.
| /* 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Updated to use WORKERS_CI_BRANCH which seems to fix it.
There was a problem hiding this comment.
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).
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
delucis
left a comment
There was a problem hiding this comment.
Looks like our patch which blocks animated images in the image service (patches/astro.patch) is no longer working, compare the first image on
- https://astro.build/themes/details/fortify-astro/
- https://cloudflare-migration.previews.astro.build/themes/details/fortify-astro/
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.
|
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. |
|
Ok, resolved most everything here:
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. |
|
Or wait, maybe not, build issue it seems. |
|
Ok, ready now. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| /* 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; |
There was a problem hiding this comment.
Reminder for us to double check this once the PR merges.
| }, | ||
| adapter: netlify({ imageCDN: false }), | ||
| adapter: cloudflare({ | ||
| imageService: 'cloudflare-binding', |
There was a problem hiding this comment.
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.
|
Merging, will check all of these things after DNS is updated. |
Migrate astro.build from Netlify to Cloudflare Workers.
DO NOT MERGE: There's a few moving parts here to deploy this.