Cookies #710
|
Is it possible to manage cookies? Or is there a better way to manage authentication? |
Replies: 3 comments
|
Hello @fabioziliani , In order to manage (read and set) cookies, you might need to connect You can achieve it by using After that, const authMw = createMiddleware({
input: z.object({}),
middleware: async ({request, response}) => {
const { cookies } = request; // here are your cookies
// do something
response.cookie('anotherOne', 'some value'); // send another cookie
return { cookies }; // provide cookies to other middlewares and endpoint handlers as options
// or just return { isAuthenticated: true } // depending on received cookie examination
}
});so the final assembly would look this way: const myFactory = defaultEndpointsFactory
.use(cookieParser())
.addMiddleware(authMw);
const myEndpoint = myFactory.build({ /* ... */ });
If this approach is not enough for your case, please provide more details on what exactly is missing or would be great to have. |
|
Hello @RobinTail and thanks for the reply. |
|
First-class cookie support added to v28.1.0, @fabioziliani |
First-class cookie support added to v28.1.0, @fabioziliani
https://ez.robintail.cz/v28.1.0/cookies