mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
524bcd563b
This PR enables Node.js core modules in edge runtime by leaving a `require` statement in the output source as externals - [x] buffer - [ ] async_hooks - [ ] util - [ ] assert - [ ] events
18 lines
389 B
JavaScript
18 lines
389 B
JavaScript
import B from 'node:buffer'
|
|
import { NextResponse } from 'next/server'
|
|
|
|
/**
|
|
* @param {Request} req
|
|
*/
|
|
export async function POST(req) {
|
|
const text = await req.text()
|
|
const buf = B.Buffer.from(text)
|
|
return NextResponse.json({
|
|
'Buffer === B.Buffer': B.Buffer === Buffer,
|
|
encoded: buf.toString('base64'),
|
|
exposedKeys: Object.keys(B),
|
|
})
|
|
}
|
|
|
|
export const runtime = 'edge'
|