You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Astro v4.11.5
Node v20.10.0
System macOS (arm64)
Package Manager pnpm
Output server
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
If you activate actions in a project that uses rewriting, you will not be able to consume the formData in a POST request.
Stack trace
TypeError
at _Request.formData (node:internal/deps/undici/undici:4684:35)
at async eval (/Users/robinjonsson/projects_demo/astro-actions-formdata/src/pages/en/post.astro:14:20)
at async callComponentAsTemplateResultOrResponse (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/runtime/server/render/astro/render.js:90:25)
at async renderToAsyncIterable (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/runtime/server/render/astro/render.js:132:26)
at async renderPage (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/runtime/server/render/page.js:31:24)
at async lastNext (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/core/render-context.js:135:25)
at async callMiddleware (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/core/middleware/callMiddleware.js:21:10)
at async RenderContext.render (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/core/render-context.js:163:22)
at async handleRoute (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/vite-plugin-astro-server/route.js:156:16)
at async run (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/vite-plugin-astro-server/request.js:40:14) {
cause: TypeError: The body has already been consumed.
at consumeBody (node:internal/deps/undici/undici:4575:19)
at consumeBody.next (<anonymous>)
at _Request.formData (node:internal/deps/undici/undici:4675:32)
at eval (/Users/robinjonsson/projects_demo/astro-actions-formdata/src/pages/en/post.astro:14:41)
at post (/Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/runtime/server/astro-component.js:19:12)
at callComponentAsTemplateResultOrResponse (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/runtime/server/render/astro/render.js:90:31)
at renderToAsyncIterable (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/runtime/server/render/astro/render.js:132:32)
at renderPage (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/runtime/server/render/page.js:31:30)
at lastNext (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/core/render-context.js:135:31)
at async callMiddleware (file:///Users/robinjonsson/projects_demo/astro-actions-formdata/node_modules/.pnpm/[email protected][email protected]/node_modules/astro/dist/core/middleware/callMiddleware.js:21:10)
}
What's the expected result?
The same result as when Astro actions are disabled.
Can you explain a bit better this use case? I need to understand if this is a real use case how you would use it. The actions feature enables a middleware that consumes the body of the Request and once it's consumed, it can't be read again.
I use rewrites and middleware for i18n support because the locales is not known at build time.
Partials for POST requests when you need to return HTML (like HTMX).
And the plan was to use actions for requests that don't need to return HTML.
Maybe it's possible to use the new Container API inside an action? 😄
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
If you activate actions in a project that uses rewriting, you will not be able to consume the formData in a POST request.
Stack trace
What's the expected result?
The same result as when Astro actions are disabled.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-rdrsul
Participation
The text was updated successfully, but these errors were encountered: