Skip to content
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

feat(trpc-server): use c.body to create response to avoid header loss #517

Merged
merged 1 commit into from
May 15, 2024

Conversation

BlankParticle
Copy link
Contributor

@BlankParticle BlankParticle commented May 14, 2024

in trpc-server middleware, we currently return the response directly which causes the respose to loose information about context. So if we set a header/cookie inside a trpc route, we don't get that in the respose.

I have fixed it by creating a new response object with c.body and returning that.

A reproduction of the issue can be found at https://github.com/BlankParticle/hono-header-reproduction/tree/main

Copy link

changeset-bot bot commented May 14, 2024

🦋 Changeset detected

Latest commit: 69a6e7a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hono/trpc-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@yusukebe
Copy link
Member

Hi @BlankParticle

Thank you for the PR. Can you see the error on the CI?

@BlankParticle
Copy link
Contributor Author

BlankParticle commented May 15, 2024

Hi @BlankParticle

Thank you for the PR. Can you see the error on the CI?

I didn't get this error while developing. Turns out I was using node 20, I was able to reproduce the errors in node 18. The fix for it is to update hono dep in the package to 4.x.x. Should I update the Hono dependency?

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Member

@BlankParticle

Thanks! Looks good. Updating Hono to v4.* is good. I'll merge this now.

@yusukebe yusukebe merged commit 8f669cd into honojs:main May 15, 2024
1 check passed
@github-actions github-actions bot mentioned this pull request May 15, 2024
@codeflows
Copy link

Thank you so much, was just struggling with this issue!

@codeflows
Copy link

It seems setting multiple cookies at once does not work, I've created a PR in the main project to try and fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants