mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
074262baf3
This PR is the initiative of deprecating the edge runtime. Proxy will default to Node.js runtime, and will not allow runtime config. If the users want to use the edge runtime, they should stay on the Middleware, though we recommend starting the migration. --------- Co-authored-by: devjiwonchoi <devjiwonchoi@gmail.com> Co-authored-by: JJ Kasper <jj@jjsweb.site>
12 lines
321 B
TypeScript
12 lines
321 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
// Will not work in edge runtime
|
|
import { join } from 'path/posix'
|
|
|
|
export function proxy(request: NextRequest) {
|
|
if (request.nextUrl.pathname === join('/', 'foo')) {
|
|
return NextResponse.redirect(new URL('/', request.url))
|
|
}
|
|
|
|
return NextResponse.next()
|
|
}
|