From a33ed996df7396c6d5e2fdca77b737d213c17065 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Sun, 3 Mar 2024 18:43:41 +0100 Subject: [PATCH] Fix error in api-routes-middleware example (#62788) ## What? Currently it shows `TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer.`. It just needs to `JSON.stringify` the value as it can be an array. Closes NEXT-2674 --- examples/api-routes-middleware/pages/api/cookies.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/api-routes-middleware/pages/api/cookies.ts b/examples/api-routes-middleware/pages/api/cookies.ts index 8de356368b..d13e73af41 100644 --- a/examples/api-routes-middleware/pages/api/cookies.ts +++ b/examples/api-routes-middleware/pages/api/cookies.ts @@ -5,5 +5,5 @@ export default function handler(_req: NextApiRequest, res: NextApiResponse) { // Calling our pure function using the `res` object, it will add the `set-cookie` header setCookie(res, "Next.js", "api-middleware!"); // Return the `set-cookie` header so we can display it in the browser and show that it works! - res.end(res.getHeader("Set-Cookie")); + res.end(JSON.stringify(res.getHeader("Set-Cookie"))); }