how to get header after use cachedEventHandler? #1466
-
In my use of cacheEventHandler to handle HTTP events, I find myself unable to retrieve the header with the line: This discrepancy led me to examine the source code of Nitro, where I found the following snippet:
From the looks of it, it seems that reqProxy is designed to disregard headers. May I ask why it is designed this way? Furthermore, if I need to access the header within the event handler, how should I go about doing so? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I think it's about security issue, to not respond to an event with response processed with a previous event (because it was cached). I think if you need to check headers (cookies, authorization, etc...) you should not use cached event handler |
Beta Was this translation helpful? Give feedback.
-
Thank you for your response. |
Beta Was this translation helpful? Give feedback.
-
Update: Nitro has added support for ignoring individual headers through cache options via the
The accepted answer still has good advice: think carefully about this pattern before you implement it since it could lead to unintended security issues. |
Beta Was this translation helpful? Give feedback.
I think it's about security issue, to not respond to an event with response processed with a previous event (because it was cached). I think if you need to check headers (cookies, authorization, etc...) you should not use cached event handler