-
Howdy! I'm writing a middleware to pass some necessary information in requests that my application receives. Is there a known method to set a custom request header for a HonoRequest or is it preferred not to modify the request header and instead just pass required data via the Context getter and setter? Can I modify c.req.raw.header somehow? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi @exoup It's possible to pass data using the following techniques (not just these) Setting a custom
|
Beta Was this translation helpful? Give feedback.
-
@6km Appreciate the thorough response. I was initially using Despite not using upgradeWebSocket anywhere, I suspect I'm running into this issue #2535. Thanks! |
Beta Was this translation helpful? Give feedback.
Hi @exoup
It's possible to pass data using the following techniques (not just these)
Setting a custom
request
headerIt can be done using the
c.req.raw.headers.set()
method but it should be before callingnext()
.Please notice that when you set a
request
header from the server side, it will not be passed to the client side. This technique is only used to pass data to the route handler.Setting a custom
response
headerThis technique is used to pass data to the server through response headers.
To set a response heade…