-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: tRPC breaks when using revalidatePath
/revalidateTag
in server action
#1640
Labels
Comments
Allypost
added a commit
to Allypost/create-t3-app
that referenced
this issue
Nov 1, 2023
Prevent tRPC from breaking when a `revalidateTag` or `revalidatePage` is used inside a server action that targets the page.
Allypost
added a commit
to Allypost/create-t3-app
that referenced
this issue
Nov 1, 2023
Prevent tRPC from breaking when a `revalidateTag` or `revalidatePage` is used inside a server action that targets the page. Refs: t3-oss#1640
3 tasks
we should just forward the cookies i think. there are more headers that seem to break stuff and it's only really the cookie we want to be able to auth users. any extra headers can be added by individual needs (#1644)? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: