Something like this could work:
JSON post requests are the same as GET requests, you just have to specify the payload and method:
const request = {
url: 'https://example.com',
method: 'POST',
payload: JSON.stringify({ foo: 'bar' }),
then in the handler of this request, you can access the response set-cookie headers:
router.addHandler('cookies', async ({ crawler, response }) => {
const { headers } = response;
// parse necessary cookies from headers['set-cookie']
// ...
// enqueue new requests with parsed cookies
const request = {
url: 'https://example.com',
headers: {
cookie: parsedCookie,
},
};
await crawler.requestQueue.addRequest(request);
});