* Write the cookies to a response.
(
response: R,
cookiesToSet: ResponseCookies
)
| 615 | * Write the cookies to a response. |
| 616 | */ |
| 617 | async function writeResponseCookies<R extends NextResponse>( |
| 618 | response: R, |
| 619 | cookiesToSet: ResponseCookies |
| 620 | ): Promise<R> { |
| 621 | const cookiesFn = await cookies(); |
| 622 | cookiesToSet.forEach((cookie) => { |
| 623 | // response.cookies.set(cookie.name, cookie.value, cookie.options); |
| 624 | // For some reason we have to use the cookies function instead of response.cookies.set |
| 625 | // Without it, it breaks the ai assistant server actions (it thinks it is a static route). |
| 626 | cookiesFn.set(cookie.name, cookie.value, cookie.options); |
| 627 | }); |
| 628 | |
| 629 | return response; |
| 630 | } |
no test coverage detected