File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import {
2424 normalizeVisitorAuthURL ,
2525} from '@/lib/visitors' ;
2626import { serveResizedImage } from '@/routes/image' ;
27+ import { cookies } from 'next/headers' ;
2728import type { SiteURLData } from './lib/context' ;
2829export const config = {
2930 matcher : [
@@ -545,9 +546,16 @@ function appendQueryParams(url: URL, from: URLSearchParams) {
545546/**
546547 * Write the cookies to a response.
547548 */
548- function writeResponseCookies < R extends NextResponse > ( response : R , cookies : ResponseCookies ) : R {
549- cookies . forEach ( ( cookie ) => {
550- response . cookies . set ( cookie . name , cookie . value , cookie . options ) ;
549+ async function writeResponseCookies < R extends NextResponse > (
550+ response : R ,
551+ cookiesToSet : ResponseCookies
552+ ) : Promise < R > {
553+ const cookiesFn = await cookies ( ) ;
554+ cookiesToSet . forEach ( ( cookie ) => {
555+ // response.cookies.set(cookie.name, cookie.value, cookie.options);
556+ // For some reason we have to use the cookies function instead of response.cookies.set
557+ // Without it, it breaks the ai assistant server actions (it thinks it is a static route).
558+ cookiesFn . set ( cookie . name , cookie . value , cookie . options ) ;
551559 } ) ;
552560
553561 return response ;
You can’t perform that action at this time.
0 commit comments