silverwolf-x/project / test /e2e /app-dir /actions /middleware-node.js
silverwolf-x's picture
download
raw
695 Bytes
// Ensure that https://github.com/vercel/next.js/issues/56286 is fixed.
import { NextResponse } from 'next/server'
export async function middleware(req) {
if (req.nextUrl.pathname.includes('rewrite-to-static-first')) {
req.nextUrl.pathname = '/static/first'
return NextResponse.rewrite(req.nextUrl)
}
if (req.method === 'POST' && req.nextUrl.pathname.includes('body-finalize')) {
const body = await req.json()
console.log(
'Middleware - Body length: %d bytes',
new TextEncoder().encode(JSON.stringify(body)).length
)
}
return NextResponse.next()
}
/**
* @type {import('next/server').ProxyConfig}
*/
export const config = {
runtime: 'nodejs',
}

Xet Storage Details

Size:
695 Bytes
·
Xet hash:
c79a8304ee3ca8a5dac8b2260c30c032ee93ce3dff42292ba83c8c4cb79bf43e

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