I have dealt with the same and it can be solved via middleware.
import { NextResponse } from 'next/server' import requestIp from 'request-ip' export const config = { matcher: '/mp/:path*', } export function middleware(request) { const requestHeaders = new Headers(request.headers) requestHeaders.set('X-REAL-IP', requestIp.getClientIp(request) || request.ip) return NextResponse.rewrite(request.nextUrl, { request: { headers: requestHeaders, }, }) }
Ah, nice one. Thanks @petrbrzek that looks like a good solution. I’ll have to try that out next time.
Sorry, I didn’t get notifications of these comments.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I have dealt with the same and it can be solved via middleware.
Ah, nice one. Thanks @petrbrzek that looks like a good solution. I’ll have to try that out next time.
Sorry, I didn’t get notifications of these comments.