Astro Actions return a 404 on Netlify when all pages are prerendered
Astro Info
(some of this is irrelevant as this issue is specific to Netlify)
Astro v4.9.3
Node v20.11.1
System macOS (arm64)
Package Manager unknown
Output hybrid
Adapter @astrojs/netlify
Integrations @astrojs/react
Describe the Bug
👋🏼 Hey Astro friends. In trying to validate that experimental Astro Actions work well on Netlify, we found this issue. (Otherwise, it seems to work great!)
- commit deployment
output: "server", 1 prerendered page + 1 SSR page- Actions work on both pages
- commit deployment
output: "hybrid", 1 prerendered page + 1 SSR page- Actions work on both pages
- commit deployment
output: "server", 2 prerendered pages- Actions do not work on any pages
- commit deployment
output: "hybrid", 2 prerendered pages- Actions do not work on any pages
You can also reproduce this locally with netlify serve (not netlify dev).
I can see the POST /_actions/sayHello is responding with a 404.
I can see the SSR function is being invoked, but not the Action handler.
With some console.log sprinkling locally, I can see that 404 is coming from here (as opposed to line 24).
Here's the routeData returned by app.match:
routeData: {
route: '/_actions/[...path]',
type: 'endpoint',
pattern: /^\/_actions(?:\/(.*?))?$/,
params: [ '...path' ],
component: 'node_modules/astro/dist/actions/runtime/route.js',
generate: [Function (anonymous)],
pathname: undefined,
segments: [ [Array], [Array] ],
prerender: false,
redirect: undefined,
redirectRoute: undefined,
fallbackRoutes: [],
isIndex: false
}
Any ideas on where to start here? Is there any intentional special behavior in Astro when output !== 'static' but all pages are opted in to prerendering? Happy to help but I could use some pointers. Thanks!
What's the expected result?
On all four branches linked above, clicking the button should print "hello ON the server" in the Netlify Function logs, print "hello FROM the server" in the browser console, and render "hello FROM the server" on the page.
Link to Minimal Reproducible Example
https://github.com/serhalp/astro-actions-netlify-demo/branches
Participation
- [X] I am willing to submit a pull request for this issue.