This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * The fallback IP address to use if the real IP address cannot be determined. | |
| */ | |
| const FALLBACK_IP_ADDRESS = '0.0.0.0'; | |
| /** | |
| * Returns the real IP address of the client. | |
| * @param request - The incoming request. | |
| * @param cfProxy - Whether the client is behind a Cloudflare proxy. | |
| * @returns The real IP address of the client. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // example code source: https://github.com/vercel/next.js/blob/canary/examples/middleware/middleware.ts | |
| import { NextRequest, NextResponse } from 'next/server' | |
| export function middleware(request: NextRequest) { | |
| if (request.nextUrl.pathname === '/about') { | |
| return NextResponse.redirect(new URL('/redirected', request.url)) | |
| } | |
| if (request.nextUrl.pathname === '/another') { | |
| return NextResponse.rewrite(new URL('/rewrite', request.url)) |
NewerOlder