HonoH
Hono7mo ago
Sun

Changing the response in the middleware breaks it

As seen on the #Extending the Context type , I'm trying to do an arriValidator now to create a new middleware for the @arrirpc/schema validator (like the zValidator, which should actually just be standard validator, but whatever)
But, when I add the created arriValidator to the handler, the handler just doesn't return anything, even when the middleware clearly said for it to
export function arriValidator<T extends AObjectSchema>(schema: T): MiddlewareHandler {
  const problemSchema = problemResponse(schema);

  return async (c, next) => {
    await next();

    const responseData = await c.res.json();
    return c.json({ message: "But why." });
    // return respondWith(c, problemSchema, responseData);
  };
}
export const routes = new Hono()
  .get("/", arriValidator(HealthSchema), async (c) => {
    return c.json({
      message: "Health is OK!",
    });
  });
See response information on image
rmncySV.png
Was this page helpful?