import { NextRequest , NextResponse } from 'next/server' ; import { getFeatureFlagVariant } from '@lib/posthog-node' ; import { DISTINCT_ID_COOKIE_NAME , FEATURE_FLAGS } from '@lib/constants' ; export async function middleware ( req ) { const productVariantValue = await getFeatureFlagVariant ( req . cookies [ DISTINCT_ID_COOKIE_NAME ] , FEATURE_FLAGS . NEW_PRODUCT_PAGE ) ; const res = NextResponse . rewrite ( `/product/${ productVariantValue }` ) ; return res ; }