Skip to content

Commit a8fd53c

Browse files
committed
fix(handler): ensure set-cookie header is not set twice
1 parent 72b1a2a commit a8fd53c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/handler/src/fastify.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ const modifyResponseHeaders = (app: FastifyInstance, request: Request, reply: Re
4545
plugin.modify(request, headers);
4646
});
4747

48-
reply.headers(headers.getHeaders());
48+
// Exclude 'set-cookie' header to avoid duplication.
49+
// Cookies are managed by @fastify/cookie and calling reply.headers() with 'set-cookie' duplicates them.
50+
const headersToSet = headers.getHeaders();
51+
delete headersToSet["set-cookie"];
52+
53+
reply.headers(headersToSet);
4954
};
5055

5156
export interface CreateHandlerParams {

0 commit comments

Comments
 (0)