mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Testmode is refactored to support both serverless and edge functions under a sandbox.
21 lines
464 B
TypeScript
21 lines
464 B
TypeScript
import { get } from 'node:https'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
export async function GET() {
|
|
const text = await new Promise<string>((resolve, reject) => {
|
|
get('https://example.com', (res) => {
|
|
let data = ''
|
|
res.on('data', (chunk) => {
|
|
data += chunk
|
|
})
|
|
res.on('end', () => {
|
|
resolve(data)
|
|
})
|
|
}).on('error', (err) => {
|
|
reject(err)
|
|
})
|
|
})
|
|
return new Response(JSON.stringify({ text }))
|
|
}
|