-
Hello, I am currently working with express-zod-api and trying to set cookies directly in the response object within a handler. However, I noticed that the response object is not directly available in the handler's parameters as shown below: export const test = defaultEndpointsFactory.build({
method: "post",
tag: "test",
description: "test",
input: z.object({}),
output: z.object({
test: z.string(),
}),
handler: async ({ input }) => {
// I need to use response.set here
// Example:
// response.set("Set-Cookie", `test=${test}; HttpOnly; Secure; Path=/; Max-Age=3600`);
const test = "value";
return {
test
};
}
}); Could you advise on how I can modify the handler or the factory setup so that I can access the response object to use methods like response.set for setting cookies? I am looking to manage HTTP headers directly, particularly for setting cookies. Thank you for your assistance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello @yuuri111 Here are existing topics for you on that matter: In short:
Please let me know if more information required. |
Beta Was this translation helpful? Give feedback.
Hello @yuuri111
Here are existing topics for you on that matter:
In short:
request
is only available for middlewares and Result Handlers.request
from a custom middleware, to access it fromoptions
in endpoint's handler.Please let me know if more information required.