From 51c30e2b42ad98d25060b3772879b3e414cfec0e Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 2 Apr 2026 16:04:43 -0400 Subject: [PATCH] Skip actions server-output validation when an adapter is configured --- .changeset/actions-static-with-adapter.md | 5 +++++ packages/astro/src/actions/integration.ts | 2 +- packages/astro/test/actions.test.js | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .changeset/actions-static-with-adapter.md diff --git a/.changeset/actions-static-with-adapter.md b/.changeset/actions-static-with-adapter.md new file mode 100644 index 000000000000..69376273c8e4 --- /dev/null +++ b/.changeset/actions-static-with-adapter.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes Actions failing with `ActionsWithoutServerOutputError` when using `output: 'static'` with an adapter diff --git a/packages/astro/src/actions/integration.ts b/packages/astro/src/actions/integration.ts index e8a5d5a002c2..562700eb55f0 100644 --- a/packages/astro/src/actions/integration.ts +++ b/packages/astro/src/actions/integration.ts @@ -41,7 +41,7 @@ export default function astroIntegrationActionsRouteHandler({ }); }, 'astro:routes:resolved': ({ routes }) => { - if (!hasNonPrerenderedRoute(routes)) { + if (!settings.config.adapter && !hasNonPrerenderedRoute(routes)) { const error = new AstroError(ActionsWithoutServerOutputError); error.stack = undefined; throw error; diff --git a/packages/astro/test/actions.test.js b/packages/astro/test/actions.test.js index 59af60e5faae..7438477dd512 100644 --- a/packages/astro/test/actions.test.js +++ b/packages/astro/test/actions.test.js @@ -476,6 +476,25 @@ describe('Astro Actions in static mode with prerender = false routes', () => { }); }); +it('Works with adapter and all pages prerendered', async () => { + const fixture = await loadFixture({ + root: './fixtures/actions/', + output: 'static', + adapter: testAdapter(), + }); + const devServer = await fixture.startDevServer(); + const res = await fixture.fetch('/_actions/subscribe', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ channel: 'bholmesdev' }), + }); + + assert.equal(res.ok, true); + await devServer.stop(); +}); + it('Base path should be used', async () => { const fixture = await loadFixture({ root: './fixtures/actions/',