Skip to content

Commit cd4ee10

Browse files
committed
fix: enable middleware to get search in layout
Signed-off-by: Innei <[email protected]>
1 parent b9608de commit cd4ee10

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

src/middleware.ts

+1-26
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { NextResponse } from 'next/server'
22
import type { NextRequest } from 'next/server'
33

4-
// import countries from '~/data/countries.json'
5-
64
import {
75
REQUEST_GEO,
86
REQUEST_HOST,
@@ -39,27 +37,6 @@ export default async function middleware(req: NextRequest) {
3937
requestHeaders.set(REQUEST_IP, ip || '')
4038
requestHeaders.set(REQUEST_HOST, headers.get('host') || '')
4139

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-
6340
return NextResponse.next({
6441
request: {
6542
headers: requestHeaders,
@@ -76,8 +53,6 @@ export const config = {
7653
* - _next/image (image optimization files)
7754
* - favicon.ico (favicon file)
7855
*/
79-
// '/((?!api|_next/static|_next/image|favicon.ico|sw.js).*)',
80-
// DISABLE
81-
'/nothing',
56+
'/((?!api|_next/static|_next/image|favicon.ico|sw.js).*)',
8257
],
8358
}

0 commit comments

Comments
 (0)