Hi all!
I am planning to deploy a Next.js application with a Upstash ratelimiter in the middleware and would want to have the middleware run as close to the Redis instance as possible.
I have tried setting the region with preferredRegion
export const preferredRegion = 'iad1'
export const config = {
matcher: [
'/((?!api|_next/static|_next/image|favicon|assets).*)',
],
}
// This function can be marked `async` if using `await` inside
export async function middleware(request: NextRequest) {
return NextResponse.next()
}
and with config.regions like so
export const config = {
matcher: [
'/((?!api|_next/static|_next/image|favicon|assets).*)',
],
regions: ['iad1'],
}
// This function can be marked `async` if using `await` inside
export async function middleware(request: NextRequest) {
return NextResponse.next()
}
None of these options seem to work as middleware is still executed in the datacenter closest to me (I verified this with a API request to a a public endpoint that returns the IP of the middleware).
Should it be possible to set the region of the middleware or not?
I though also about running multiple Redis instances and using multiregionRateLimit but that would incur an additional cost.
PS. I’m testing this on Hobby plan.