Skip to content

Commit b5c2fba

Browse files
authored
Skip actions server-output validation when an adapter is configured (#16202)
1 parent b06eabf commit b5c2fba

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes Actions failing with `ActionsWithoutServerOutputError` when using `output: 'static'` with an adapter

packages/astro/src/actions/integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default function astroIntegrationActionsRouteHandler({
4141
});
4242
},
4343
'astro:routes:resolved': ({ routes }) => {
44-
if (!hasNonPrerenderedRoute(routes)) {
44+
if (!settings.config.adapter && !hasNonPrerenderedRoute(routes)) {
4545
const error = new AstroError(ActionsWithoutServerOutputError);
4646
error.stack = undefined;
4747
throw error;

packages/astro/test/actions.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,25 @@ describe('Astro Actions in static mode with prerender = false routes', () => {
476476
});
477477
});
478478

479+
it('Works with adapter and all pages prerendered', async () => {
480+
const fixture = await loadFixture({
481+
root: './fixtures/actions/',
482+
output: 'static',
483+
adapter: testAdapter(),
484+
});
485+
const devServer = await fixture.startDevServer();
486+
const res = await fixture.fetch('/_actions/subscribe', {
487+
method: 'POST',
488+
headers: {
489+
'Content-Type': 'application/json',
490+
},
491+
body: JSON.stringify({ channel: 'bholmesdev' }),
492+
});
493+
494+
assert.equal(res.ok, true);
495+
await devServer.stop();
496+
});
497+
479498
it('Base path should be used', async () => {
480499
const fixture = await loadFixture({
481500
root: './fixtures/actions/',

0 commit comments

Comments
 (0)