1
1
import { NextResponse } from 'next/server'
2
2
import type { NextRequest } from 'next/server'
3
3
4
- // import countries from '~/data/countries.json'
5
-
6
4
import {
7
5
REQUEST_GEO ,
8
6
REQUEST_HOST ,
@@ -39,27 +37,6 @@ export default async function middleware(req: NextRequest) {
39
37
requestHeaders . set ( REQUEST_IP , ip || '' )
40
38
requestHeaders . set ( REQUEST_HOST , headers . get ( 'host' ) || '' )
41
39
42
- const isApi = pathname . startsWith ( '/api/' )
43
-
44
- if ( geo && ! isApi && process . env . VERCEL_ENV ) {
45
- const country = geo . country
46
- // const city = geo.city
47
-
48
- // const countryInfo = countries.find((x) => x.cca2 === country)
49
- // if (countryInfo) {
50
- // try {
51
- // const ipKey = `visitor_ip_${dayjs().format('YYYY-MM-DD')}`
52
- // await redis.sadd(ipKey, ip)
53
- // const countryInfo = countries.find((x) => x.cca2 === country)
54
- // if (countryInfo) {
55
- // const flag = countryInfo.flag
56
- // await redis.set(kvKeys.currentVisitor, { country, city, flag })
57
- // }
58
- // await redis.expire(ipKey, 60 * 60 * 24 * 7)
59
- // } catch {}
60
- // }
61
- }
62
-
63
40
return NextResponse . next ( {
64
41
request : {
65
42
headers : requestHeaders ,
@@ -76,8 +53,6 @@ export const config = {
76
53
* - _next/image (image optimization files)
77
54
* - favicon.ico (favicon file)
78
55
*/
79
- // '/((?!api|_next/static|_next/image|favicon.ico|sw.js).*)',
80
- // DISABLE
81
- '/nothing' ,
56
+ '/((?!api|_next/static|_next/image|favicon.ico|sw.js).*)' ,
82
57
] ,
83
58
}
0 commit comments