mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This test is about `eval` But it also used a non-static middleware `matchers` config, which is going to break once we are more strict about this and throw a build error.
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
import { NextResponse } from 'next/server'
|
|
import { notUsingEval, usingEval } from './lib/utils'
|
|
import {
|
|
usingWebAssemblyCompile,
|
|
usingWebAssemblyInstantiate,
|
|
usingWebAssemblyInstantiateWithBuffer,
|
|
} from './lib/wasm'
|
|
|
|
export async function middleware(request) {
|
|
if (request.nextUrl.pathname === '/using-eval') {
|
|
return new Response(null, {
|
|
headers: { data: JSON.stringify(await usingEval()) },
|
|
})
|
|
}
|
|
|
|
if (request.nextUrl.pathname === '/not-using-eval') {
|
|
return new Response(null, {
|
|
headers: { data: JSON.stringify(await notUsingEval()) },
|
|
})
|
|
}
|
|
|
|
if (request.nextUrl.pathname === '/using-webassembly-compile') {
|
|
return new Response(null, {
|
|
headers: { data: JSON.stringify(await usingWebAssemblyCompile(9)) },
|
|
})
|
|
}
|
|
|
|
if (request.nextUrl.pathname === '/using-webassembly-instantiate') {
|
|
return new Response(null, {
|
|
headers: { data: JSON.stringify(await usingWebAssemblyInstantiate(9)) },
|
|
})
|
|
}
|
|
|
|
if (
|
|
request.nextUrl.pathname === '/using-webassembly-instantiate-with-buffer'
|
|
) {
|
|
return new Response(null, {
|
|
headers: {
|
|
data: JSON.stringify(await usingWebAssemblyInstantiateWithBuffer(9)),
|
|
},
|
|
})
|
|
}
|
|
|
|
return NextResponse.next()
|
|
}
|
|
|
|
export const config = {
|
|
matcher: [
|
|
'/using-eval',
|
|
'/not-using-eval',
|
|
'/using-webassembly-compile',
|
|
'/using-webassembly-instantiate',
|
|
'/using-webassembly-instantiate-with-buffer',
|
|
],
|
|
}
|