Instant Edge Personalization Without Origin Roundtrips
Modern global web applications must adapt dynamically to visitor geographic locations: displaying local currency, enforcing GDPR cookie consent in the European Union, and redirecting users to regional language subpaths (e.g. /de/ or /jp/). Performing geolocation lookups on origin application servers introduces hundreds of milliseconds of latency. In Next.js 15, executing lightweight edge middleware directly at CDN edge nodes resolves country headers in under 5 milliseconds with zero origin hits.
Authored by Saizul Amin for frontend systems engineers and edge architecture developers.
Implementation: Edge Middleware with Country Header Rewrites
// middleware.ts
import { NextRequest, NextResponse } from '\''next/server'\'';
export function middleware(request: NextRequest) {
// Read country header injected by Cloudflare / Vercel Edge Network
const country = request.headers.get('\''x-vercel-ip-country'\'') ||
request.headers.get('\''cf-ipcountry'\'') || '\''US'\'';
const response = NextResponse.next();
response.headers.set('\''x-user-country'\'', country);
// If EU visitor, set header flag for strict GDPR consent banner
const euCountries = ['\''DE'\'', '\''FR'\'', '\''IT'\'', '\''ES'\'', '\''NL'\'', '\''SE'\'', '\''PL'\''];
if (euCountries.includes(country)) {
response.headers.set('\''x-require-gdpr-consent'\'', '\''true'\'');
}
return response;
}
export const config = {
matcher: ['\''/((?!api|_next/static|_next/image|favicon.ico).*)'\''],
};

Saizul Amin is a digital growth strategist and SEO consultant specialising in search engine optimisation, web development, AI-powered automation, and online income systems. With 8 years of hands-on experience helping businesses and individual creators grow their online presence, Saizul combines technical expertise with practical, results-driven strategy.
Experience & Background
Saizul started his digital career in 2017, initially working with Bioscope Limited to build and optimise websites for organic search traffic. Over the years, he has worked across industries including DGHS, NAVANA, UNICampus, UNIPathways, UniqueMark, developing a deep understanding of what it takes to rank, convert, and grow sustainably online.
His work spans the full digital stack — from technical SEO audits and content strategy to WordPress development, marketing automation, and AI tool integration for small businesses and startups.
What He Covers on This Blog
Every article on SaizulAmin.com is written from direct experience. Saizul does not publish theoretical content — every guide, tool recommendation, and strategy shared here has been tested and applied in real projects. Topics include:
- Search engine optimisation (on-page, technical, and content SEO)
- Digital marketing strategy and growth systems
- AI tools and automation for business productivity
- Web development, WordPress, and website building
- Making money online through freelancing and affiliate marketing
Why Trust This Content
All recommendations on this site reflect tools and strategies Saizul actively uses or has personally evaluated. Where affiliate relationships exist, they are clearly disclosed. Content is regularly reviewed and updated to reflect current best practices and algorithm changes.
