Buckets:
| import type { NextRequest } from 'next/server' | |
| import { NextResponse } from 'next/server' | |
| export function middleware(request: NextRequest) { | |
| if ( | |
| request.nextUrl.pathname.startsWith('/headers/') || | |
| request.nextUrl.pathname.endsWith('dynamic_api_headers') | |
| ) { | |
| // Clone the request headers and set a new header `x-hello-from-middleware1` | |
| const requestHeaders = new Headers(request.headers) | |
| requestHeaders.set('x-sentinel', 'hello') | |
| requestHeaders.set('x-sentinel-path', request.nextUrl.pathname) | |
| requestHeaders.set( | |
| 'x-sentinel-rand', | |
| ((Math.random() * 100000) | 0).toString(16) | |
| ) | |
| return NextResponse.next({ | |
| request: { | |
| // New request headers | |
| headers: requestHeaders, | |
| }, | |
| }) | |
| } | |
| const response = NextResponse.next() | |
| if ( | |
| request.nextUrl.pathname.startsWith('/cookies/') || | |
| request.nextUrl.pathname.endsWith('dynamic_api_cookies') | |
| ) { | |
| response.cookies.set('x-sentinel', 'hello', { | |
| httpOnly: true, | |
| sameSite: 'strict', | |
| maxAge: 60 * 60 * 24 * 7, // 1 week | |
| path: '/', | |
| }) | |
| response.cookies.set('x-sentinel-path', request.nextUrl.pathname, { | |
| httpOnly: true, | |
| sameSite: 'strict', | |
| maxAge: 60 * 60 * 24 * 7, // 1 week | |
| path: '/', | |
| }) | |
| response.cookies.set( | |
| 'x-sentinel-rand', | |
| ((Math.random() * 100000) | 0).toString(16), | |
| { | |
| httpOnly: true, | |
| sameSite: 'strict', | |
| maxAge: 60 * 60 * 24 * 7, // 1 week | |
| path: '/', | |
| } | |
| ) | |
| } | |
| return response | |
| } | |
Xet Storage Details
- Size:
- 1.55 kB
- Xet hash:
- e02e3bd3a26535ad58d01479786b5ebe47bca8e42a033957e07c421e97ace15b
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.