mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
0d5b42c79e
Updated the production server to handle binary responses correctly by using Buffer.from with arrayBuffer instead of text(). Added a test to ensure binary data integrity and created a new fixture for testing binary API responses.
10 lines
445 B
TypeScript
10 lines
445 B
TypeScript
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
export default function handler(_req: NextApiRequest, res: NextApiResponse) {
|
|
// Leading bytes are intentionally invalid UTF-8; if a text decode/encode
|
|
// path is introduced, this payload will be visibly corrupted.
|
|
const body = Buffer.from([0xff, 0xfe, 0xfd, 0x00, 0x61, 0x62, 0x63]);
|
|
res.setHeader("Content-Type", "application/octet-stream");
|
|
res.status(200).end(body);
|
|
}
|