Created
March 9, 2022 06:25
-
-
Save velotiotech/6657a8ce10ad7bea0f597f933d62c941 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { NextFetchEvent } from 'next/server'; | |
import { NextResponse } from 'next/server'; | |
export function middleware(event: NextFetchEvent) { | |
// gram the user's location or use India for default | |
const country = event.request.geo.country.toLowerCase() || 'IND'; | |
//rewrite to static, cached page for each local | |
return event.respondWith(NextResponse.rewrite(`/routeName/${country}`)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment