mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
## What? Includes the changes from 16-2. --------- Co-authored-by: JJ Kasper <[email protected]> Co-authored-by: Josh Story <[email protected]> Co-authored-by: Zack Tanner <[email protected]> Co-authored-by: Benjamin Woodruff <[email protected]>
17 lines
494 B
JavaScript
17 lines
494 B
JavaScript
import { NextResponse } from 'next/server'
|
|
import { ImageResponse } from 'next/og'
|
|
|
|
export async function middleware(req) {
|
|
console.log('middleware', req.url)
|
|
if (req.nextUrl.pathname === '/a-non-existent-page/to-test-with-middleware') {
|
|
return new ImageResponse(<div>Hello world</div>, {
|
|
width: 1200,
|
|
height: 600,
|
|
})
|
|
}
|
|
if (req.nextUrl.pathname === '/dynamic/secret') {
|
|
return new NextResponse('Unauthorized', { status: 401 })
|
|
}
|
|
return NextResponse.next()
|
|
}
|