mirror of
https://github.com/System-End/site.git
synced 2026-04-19 18:35:12 +00:00
* A small test
* continental 🌴
* Hmm
* Update use-form.js
* Update _middleware.js
* Update _middleware.js
* I think I got it!
* Try using rewrite
* Update _middleware.js
14 lines
418 B
JavaScript
14 lines
418 B
JavaScript
import { NextResponse } from 'next/server'
|
|
import country from 'country-list-js';
|
|
|
|
export function middleware(req) {
|
|
let url = req.nextUrl
|
|
if(!url.searchParams.get("continent")){
|
|
let continent = country.findByIso2(req.geo.country || "AU").continent
|
|
if(continent == "Oceania"){
|
|
continent = "Australia"
|
|
}
|
|
url.searchParams.set("continent", continent)
|
|
return NextResponse.redirect(url)
|
|
}
|
|
}
|