Files
Niklas MischkulnigandGitHub c2b5142640 otel: Use correct parent span for Node.js middleware (#95306)
Node.js Middleware was inheriting the wrong parent span (and behaved
differently compared to Edge runtime Middleware)

`Middleware.execute` and `BaseServer.handleRequest` should be sibling
spans (depending on context, both are root spans). Previously
`BaseServer.handleRequest` had a child span `Middleware.execute`

Depends on https://github.com/vercel/next.js/pull/95357 to make the
direct entrypoint test pass
2026-07-06 14:53:45 +02:00

15 lines
356 B
TypeScript

import type { NextRequest, NextFetchEvent } from 'next/server'
import { NextResponse } from 'next/server'
export const config = {
matcher: ['/behind-middleware', '/behind-middleware/:path*'],
runtime: 'nodejs',
}
export async function middleware(
request: NextRequest,
event?: NextFetchEvent
): Promise<Response> {
return NextResponse.next()
}