Middleware forward headers to other functions

Hello, I am building a next application and I have a middleware where I add the href in a header. Then I access it in some server components. It's working correctly on Vercel and locally but on Cloudflare, the header is not forwarded to the server components.

Do I need to add something else?
Or do you have another solution? I want to access some query params in a nextjs layout but from what I know it's not directly possible right now.

Thanks.

Example:

export function middleware(request: NextRequest) {
  const response = NextResponse.next();

  response.headers.append('x-href', request.nextUrl.href);

 
  return response;
}
Was this page helpful?