Skip to content

Commit a194c77

Browse files
committed
add googlebot middleware
1 parent f07b911 commit a194c77

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

docs/working-notes/notes4.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ cache invalidate fails?
1919
mozda samo portainer container recreate fails
2020
----
2121
N new ads since yesterday, both debugging and ui, compare last month updatedAt // dobar feature
22-
deleteLastNMonths for test updating
22+
deleteLastNMonths to debug updating
2323
remove plausible proxy for country, open issue and ask

middleware.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NextResponse } from 'next/server';
2+
3+
import logger from '@/libs/winston';
4+
5+
import type { NextRequest } from 'next/server';
6+
7+
export const middleware = (request: NextRequest) => {
8+
const userAgentString = request.headers.get('user-agent') ?? '';
9+
10+
if (userAgentString.includes('Googlebot'))
11+
logger.info(
12+
`Googlebot detected, pathname: ${request.nextUrl.pathname}, userAgentString: ${userAgentString}`
13+
);
14+
15+
return NextResponse.next();
16+
};

0 commit comments

Comments
 (0)