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
The response object is not properly populated according to the Response TypeScript definition. There is only a "body" property. I am attempting to write headers.
My understanding is this by design of Nitro hooks. The body is whatever was returned. I'm thinking we should probably just wrap this differently and not use their conventions as it is odd. We must have typed things wrong.
Generally use setHeader rather than try to manipulate the response directly I think might be the coarse of action. This does deserve more discussion though.
Yeah after some further digging this does seem to be the behavior. I agree its odd. Coming from other API's I am used to set the headers on the response, I should have realized there was a solid-start provided API to do that. Which now makes me think of what is the purpose of the provided Nitro response. I guess it is useful if someone really needs to dig into something. But if its kept, then yeah should at least have some more accurate typings.
It seems the design was intentional so people could swap the response, but we could just change the API here to suit our needs I think. I'm open to discussion on that. The reason I want the response there is so I can look at it mostly. I suppose if what I got was an Error I might want to send back a different response. I should see how it cascades through. Part of this comes from better understanding the current behavior too.
Duplicates
Latest version
Current behavior 😯
The response object is not properly populated according to the Response TypeScript definition. There is only a "body" property. I am attempting to write headers.
Expected behavior 🤔
The response object, if provided inside onBeforeResponse, should be populated and usable.
Steps to reproduce 🕹
Steps:
Context 🔦
I am trying to find a way to write response headers for the user, as well as access response headers for logging.
Your environment 🌎
The text was updated successfully, but these errors were encountered: