跳转到内容

setNextProxyHeaders

此内容尚不支持你的语言。

setNextProxyHeaders(request, response): void

Defined in: nextjs/middleware.ts:56

Next.js middleware helper for forwarding test proxy recording headers Automatically forwards the recording ID header from incoming requests to the proxy Only runs in non-production environments or when TEST_PROXY_RECORDER_ENABLED is set

NextJSRequest

Next.js request object (NextRequest from next/server)

NextJSResponse

Next.js response object (NextResponse from next/server)

void

middleware.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
import { setNextProxyHeaders } from 'test-proxy-recorder/nextjs';
export function middleware(request: NextRequest) {
const response = NextResponse.next();
// Only forwards headers in test/dev environments
setNextProxyHeaders(request, response);
return response;
}