-
-
Notifications
You must be signed in to change notification settings - Fork 840
Open
Labels
enhancementNew feature or request.New feature or request.
Description
What is the feature you are proposing?
Whenever I use hono/timing, I end up having to wrap it to avoid TypeError: Can't modify immutable headers..
import type { MiddlewareHandler } from "hono";
import { timing } from "hono/timing";
type TimingConfig = Parameters<typeof timing>[0];
export default (config?: TimingConfig): MiddlewareHandler => {
return async (c, next) => {
return await timing(config)(c, async () => {
await next();
// Ensure the response is mutable
if (c.res instanceof Response) {
c.res = new Response(c.res.body, c.res);
}
});
};
};Because that middleware is likely to be book-ending the entire middleware chain, it seems like a common pitfall.
Think it would be worth including in the middleware itself?
If so, I'm happy to PR.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request.New feature or request.