react-code-dataset / next.js /test /production /standalone-mode /required-server-files /middleware.js
Download next.js/test/production/standalone-mode/required-server-files/middleware.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 377 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/production/standalone-mode/required-server-files/middleware.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/production/standalone-mode/required-server-files/middleware.js
-
curl -L -o middleware.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/production/standalone-mode/required-server-files/middleware.js
377 Bytes
| 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, | |
| }) | |
| } | |
| return NextResponse.next() | |
| } | |