bug: tRPC breaks when using revalidatePath
/revalidateTag
in server action
#1640
Labels
revalidatePath
/revalidateTag
in server action
#1640
Provide environment information
Describe the bug
The issue occurs when using both server actions and tRPC inside the same component.
If a
revalidatePath
is used inside the server action, the component breaks after submitting the form with the errorThis is because the tRPC proxy as is implemented in the current way forwards all headers. The issue is that next generates additional content and thus breaks the
content-length
header.The (temporary) fix is to omit the
content-length
header in the requests.Adding
heads.delete("content-length")
in the tRPC providers should solve that.Reproduction repo
https://github.com/Allypost/create-t3-app-trpc-breaks-server-actions
To reproduce
Run the provided repo and simply click the "Broken" button.
Alternatively, add a server action with a
revalidatePath
to a page that has a server-component tRPC requestAdditional information
Error screenshot
The text was updated successfully, but these errors were encountered: