Skip to content

Commit

Permalink
fix: split set-cookie value when handling web responses (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hebilicious authored Jul 17, 2023
1 parent d11f817 commit edeb5dc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/utils/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Socket } from "node:net";
import type { H3Event } from "../event";
import { MIMES } from "./consts";
import { sanitizeStatusCode, sanitizeStatusMessage } from "./sanitize";
import { splitCookiesString } from "./cookie";

const defer =
typeof setImmediate === "undefined" ? (fn: () => any) => fn() : setImmediate;
Expand Down Expand Up @@ -276,9 +277,14 @@ export function writeEarlyHints(
}

export function sendWebResponse(event: H3Event, response: Response) {
for (const [key, value] of response.headers.entries()) {
event.node.res.setHeader(key, value);
for (const [key, value] of response.headers) {
if (key === "set-cookie") {
event.node.res.setHeader(key, splitCookiesString(value));
} else {
event.node.res.setHeader(key, value);
}
}

if (response.status) {
event.node.res.statusCode = sanitizeStatusCode(
response.status,
Expand Down

0 comments on commit edeb5dc

Please sign in to comment.