From a0ef1548883d3e5998da33d6d1bcae9e04173e28 Mon Sep 17 00:00:00 2001 From: Aiji Uejima Date: Mon, 2 May 2022 17:38:23 +0900 Subject: [PATCH] chore: update example --- example/src/pages/ip/_middleware.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/example/src/pages/ip/_middleware.ts b/example/src/pages/ip/_middleware.ts index 9fd108a..e85a4a6 100644 --- a/example/src/pages/ip/_middleware.ts +++ b/example/src/pages/ip/_middleware.ts @@ -6,7 +6,9 @@ export const middleware: NextMiddleware = (req, event) => { const ips = req.cookies['__allowed_ips'] if (!ips) { if (req.preflight) return new NextResponse(null) - return NextResponse.redirect('/ip') + const url = req.nextUrl.clone() + url.pathname = '/ip' + return NextResponse.redirect(url) } return makeIPInspector(ips.split(','), {