diff --git a/.changeset/fix-content-authors-wiring.md b/.changeset/fix-content-authors-wiring.md new file mode 100644 index 0000000000..159766b1e0 --- /dev/null +++ b/.changeset/fix-content-authors-wiring.md @@ -0,0 +1,5 @@ +--- +"emdash": patch +--- + +Fixes the admin author filter returning HTTP 500 (`NOT_CONFIGURED` / "EmDash is not initialized") for every collection. The `handleContentAuthors` handler was never exposed on the per-request `locals.emdash` object in middleware, so `GET /_emdash/api/content/{collection}/authors` always tripped its not-initialized guard while sibling content routes worked normally. diff --git a/packages/core/src/astro/middleware.ts b/packages/core/src/astro/middleware.ts index 06bb3b36b3..b76ee4d09c 100644 --- a/packages/core/src/astro/middleware.ts +++ b/packages/core/src/astro/middleware.ts @@ -591,6 +591,7 @@ export const onRequest = defineMiddleware(async (context, next) => { // Content handlers handleContentList: runtime.handleContentList.bind(runtime), handleContentGet: runtime.handleContentGet.bind(runtime), + handleContentAuthors: runtime.handleContentAuthors.bind(runtime), handleContentCreate: runtime.handleContentCreate.bind(runtime), handleContentUpdate: runtime.handleContentUpdate.bind(runtime), handleContentDelete: runtime.handleContentDelete.bind(runtime), diff --git a/packages/core/tests/unit/astro/middleware-prerender.test.ts b/packages/core/tests/unit/astro/middleware-prerender.test.ts index d58ed8cd44..b16470b07c 100644 --- a/packages/core/tests/unit/astro/middleware-prerender.test.ts +++ b/packages/core/tests/unit/astro/middleware-prerender.test.ts @@ -38,6 +38,7 @@ const { configuredPlugins: [], handleContentList: ok, handleContentGet: ok, + handleContentAuthors: ok, handleContentCreate: ok, handleContentUpdate: ok, handleContentDelete: ok, @@ -232,6 +233,10 @@ describe("astro middleware prerendered routes", () => { const emdash = locals.emdash as Record; expect(typeof emdash.handlePluginApiRoute).toBe("function"); expect(typeof emdash.handlePublicPluginApiRoute).toBe("function"); + // Regression for #1462: the author filter route reads + // `locals.emdash.handleContentAuthors`; it must be wired onto the + // runtime helpers object or every `/authors` request 500s. + expect(typeof emdash.handleContentAuthors).toBe("function"); }); it("does not access context.session when prerendering public pages", async () => {