Skip to content

Instantly share code, notes, and snippets.

@neilkillen
Last active August 19, 2022 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilkillen/13fbc852dc25eb0334a6ecaf471dad67 to your computer and use it in GitHub Desktop.
Save neilkillen/13fbc852dc25eb0334a6ecaf471dad67 to your computer and use it in GitHub Desktop.
/**
** Middleware Function to rewrite shops url based on user information stored in Sitecore Personalize
* @param req
* @returns NextResponse with a rewrite set
*/
export function middleware(req: NextRequest){
// Check if request is seasonal content and handle request to personalize experience
if(req.nextUrl.pathname.startsWith("/seasonal"))
{
return handleSeasonalRequest(req)
}
// Check if request is store content and handle request to personalize experience
if(req.nextUrl.pathname.startsWith("/store"))
{
return handleStoreRequest(req)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment