-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.js
More file actions
19 lines (17 loc) · 804 Bytes
/
Copy pathproxy.js
File metadata and controls
19 lines (17 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Next.js 16 doi ten "middleware" thanh "proxy". Dat ten file la middleware.js
// thi no KHONG chay, va trang admin se mo toang ma nhin ben ngoai van tuong la
// da khoa. Xem node_modules/next/dist/docs/01-app/01-getting-started/16-proxy.md
import { NextResponse } from 'next/server';
import { ADMIN_COOKIE } from './lib/adminSession';
// Chi kiem tra so bo (co cookie hay khong) theo dung khuyen nghi cua Next:
// proxy chay tren moi request ke ca prefetch nen khong lam viec nang o day.
// Xac minh chu ky that nam trong app/admin/disputes/page.jsx.
export function proxy(request) {
if (!request.cookies.has(ADMIN_COOKIE)) {
return NextResponse.redirect(new URL('/admin/login', request.url));
}
return NextResponse.next();
}
export const config = {
matcher: '/admin/disputes/:path*',
};