Complete the code to specify the Edge runtime in a Next.js API route.
export const runtime = [1];Setting runtime to "edge" tells Next.js to use the Edge runtime for this API route.
Complete the code to import a Node.js-only module in a Next.js API route using Node.js runtime.
export const runtime = [1];Node.js runtime allows using Node.js-only modules like fs or path.
Fix the error in this Edge runtime API route that tries to use the 'fs' module.
export const runtime = [1]; import fs from 'fs'; export async function GET() { const data = fs.readFileSync('/data.txt', 'utf8'); return new Response(data); }
fs to work.The fs module is not available in the Edge runtime. Switching to "nodejs" runtime fixes this.
Fill both blanks to create a Next.js API route that uses Edge runtime and returns a JSON response.
export const runtime = [1]; export async function GET() { return new Response(JSON.stringify({ message: [2] }), { headers: { 'Content-Type': 'application/json' } }); }
Setting runtime to "edge" enables Edge runtime. The message string is returned as JSON.
Fill all three blanks to create a Next.js API route that uses Node.js runtime, reads a file, and returns its content.
export const runtime = [1]; import [2] from 'fs'; export async function GET() { const content = [3].readFileSync('example.txt', 'utf8'); return new Response(content); }
Node.js runtime is set with "nodejs". The fs module is imported and used to read the file synchronously.