Setting cookies from server in Nextjs

Hi… Can someone tell mw how to set cookies from server in Nextjs onto the browser.
I am using … the following in an api route & it isnt working.

also if theres a way to read cookies in the code interactions in plasmic…

import type { NextApiRequest, NextApiResponse } from 'next';
import { getCookies, getCookie, setCookie, deleteCookie } from 'cookies-next';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {

  setCookie('server-key', 'value', { req, res, maxAge: 60 * 60 * 24 });
    return res.status(200).json({ message: 'ok' });
}

After the Api Call… I inspected the network… & found response… which has set-cookie header …but it still not setting them in the browser…

Some more info on call : Request URL:
https://data.plasmic.app/api/v1/server-data/sources/someid/executeRequest Method:
POSTStatus Code:
200 OKRemote Address:
18.66.63.48:443Referrer Policy:
strict-origin-when-cross-origin
Response Headers
Request Headers
Number of cookies shown in table: 17

{
“data”: {
“response”: {
“message”: “Authentication successful”
},
“statusCode”: 200,
“headers”: {
“connection”: “close”,
“content-length”: “39”,
“content-type”: “application/json; charset=utf-8”,
“date”: “Sun, 26 Nov 2023 11:32:59 GMT”,
“etag”: “"cosxoiyyhr13"”,
“set-cookie”: “Token=dummytoken123” Max-Age=604800; Path=/",
“vary”: “Accept-Encoding”
}
}
}