silverwolf-x's picture
download
raw
1.01 kB
import { NextRequest, NextResponse } from 'next/server'
// Simulates what might happen if a proxy or firewall modifies the
// request based on a condition that changes after the prefetch but before
// the actual navigation.
//
// The proxy modifies the request based on special search parameters, but only
// during a navigation — not during a prefetch.
export const config = {
matcher: [
{
source: '/:path*',
// Exclude prefetch requests
missing: [{ type: 'header', key: 'Next-Router-Prefetch' }],
},
],
}
export default function proxy(req: NextRequest) {
const mismatchRedirect = req.nextUrl.searchParams.get('mismatch-redirect')
if (mismatchRedirect) {
// Redirect to the given URL.
return NextResponse.redirect(new URL(mismatchRedirect, req.url))
}
const mismatchRewrite = req.nextUrl.searchParams.get('mismatch-rewrite')
if (mismatchRewrite) {
// Rewrite to the given URL.
return NextResponse.rewrite(new URL(mismatchRewrite, req.url))
}
}

Xet Storage Details

Size:
1.01 kB
·
Xet hash:
110c1aafaa6b30af9ada8f7692f298c96be14d4c68e629c40e28b4911fac83ba

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.