mirror of
https://github.com/vercel/flags.git
synced 2026-09-19 03:49:23 +08:00
19 lines
433 B
TypeScript
19 lines
433 B
TypeScript
import type { NextRequest } from 'next/server';
|
|
import { NextResponse } from 'next/server';
|
|
|
|
export function proxy(request: NextRequest) {
|
|
const visitorId =
|
|
request.cookies.get('visitorId')?.value ?? crypto.randomUUID();
|
|
|
|
return NextResponse.next({
|
|
headers: {
|
|
'Set-Cookie': `visitorId=${visitorId}; Path=/`,
|
|
'x-visitor-id': visitorId,
|
|
},
|
|
});
|
|
}
|
|
|
|
export const config = {
|
|
matcher: ['/', '/checkout'],
|
|
};
|