Into the Fediverse, Part 1: A Failed Attempt
On this page
I recently migrated my blog to Astro and was excited to explore its features, especially the built-in MDX support. At the same time, I discovered Fedify and thought it would be a fun project to publish my blog posts to ActivityPub. The Fedify documentation recommends Deno as its primary runtime, so I decided to go all-in with Deno, since I already have a bit experience in it.
The migration to Astro was a breeze, and I quickly deployed my new blog to Deno Deploy. The next step was integrating Fedify. I was particularly interested in using Deno KV for storage, which seemed like a natural fit since I was already on the Deno platform.
The First Hurdle: JSR vs NPM
My excitement quickly turned to confusion when I tried to run my first Fedify function and was hit with an error.
[ERROR] Cannot find module '@fedify/fedify' imported from '<project>/src/lib/publish.ts' Stack trace: at fetchModule (<project>/node_modules/.deno/vite@6.3.5_1/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:46813:19) ...
My theory is that this happened because my Astro project’s dependencies were downloaded from npm registry
(distinguished by the npm:
prefix), but I was trying to import Fedify from JSR (Deno’s native registry,
with jsr:
prefix). It seems Vite, Astro’s build tool, couldn’t resolve the import path for a JSR package.
I specifically wanted the JSR version to easily access the built-in Hono and Deno integrations
(@fedify/fedify/x/hono
and @fedify/fedify/x/deno
).
Conceding defeat on that front, I switched to the npm version of @fedify/fedify
and decided to use Redis
for storage instead of Deno KV. (Ironically, I later found out the Deno KV adapter is available on npm, but I
had already set up Redis by then).
After a bit of trial and error, I successfully generated and stored my keypair and even published a post. Seeing the records pop up in my Redis instance was a great feeling!
The Roadblock: Astro Middleware
The final piece of the puzzle was to intercept requests to the /.well-known/webfinger
path and route them to
my Fedify handler. The natural way to do this in Astro is with middleware. Unfortunately, this led to a complete
dead end.
MiddlewareCantBeLoaded: An unknown error was thrown while loading your middleware. at loadMiddleware (<project>/node_modules/.deno/astro@5.11.0_1/node_modules/astro/dist/core/middleware/loadMiddleware.js:8:24) ...
I then found an open issue on the Fedify GitHub repository. The maintainer confirmed that there’s an incompatibility with Astro’s middleware, which is a blocker for official Astro support for now. Now, the error that I got may not be directly related to the issue above, but it’s enough to stop me from continuing After spending most of my Sunday on this, it was quite frustrating.
Looking Ahead
Even with this setback, I think the Fedify team’s doing a solid job. The documentation’s straightforward and detailed, they’ve put real effort into the project, and they’re still actively working on it.
I’ll definitely give Fedify another try in the future. My next plan is to host the Fedify server separately, perhaps on my home server, and find another way to handle the Webfinger routing. But that’s a project for another day.