mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
1970f9fb16
Closes PACK-3304 This was originally done in https://github.com/vercel/next.js/pull/63209 But I don't think this is correct. Without this change, the added test fails with ``` Error: failed to pipe response at pipeToNodeResponse (/next.js/packages/next/dist/server/pipe-readable.js:126:15) at async handleRequest (/next.js/packages/next/dist/server/lib/router-server.js:275:24) at async requestHandlerImpl (/next.js/packages/next/dist/server/lib/router-server.js:384:13) at async Server.requestListener (/next.js/packages/next/dist/server/lib/start-server.js:142:13) { [cause]: TypeError [ERR_INVALID_URL]: Invalid URL at new NodeError (node:internal/errors:405:5) at new URL (node:internal/url:676:13) at /next.js/test/tmp/next-test-1729241452365-597/.next/server/edge/chunks/ssr/[project]_packages_next_dist_compiled_fd94e8._.js:31684:26 { input: '/_next/static/media/noto-sans-v27-latin-regular.7e1666d1.ttf', code: 'ERR_INVALID_URL' } } ``` (because the `blob:` prefix is missing for the font static URL)
13 lines
298 B
JavaScript
13 lines
298 B
JavaScript
import { NextResponse } from 'next/server'
|
|
import { ImageResponse } from 'next/og'
|
|
|
|
export async function middleware(req) {
|
|
if (req.nextUrl.pathname === '/middleware') {
|
|
return new ImageResponse(<div>hi</div>, {
|
|
width: 1200,
|
|
height: 630,
|
|
})
|
|
}
|
|
return NextResponse.next()
|
|
}
|