diff --git a/src/event-sources/azure/http-function-runtime-v3.js b/src/event-sources/azure/http-function-runtime-v3.js index de1c7384..4e44c86e 100644 --- a/src/event-sources/azure/http-function-runtime-v3.js +++ b/src/event-sources/azure/http-function-runtime-v3.js @@ -42,11 +42,13 @@ function getResponseToHttpFunction ({ statusCode, body, headers = {}, isBase64En } const cookies = [] - const headerCookies = headers['set-cookie'] - + // headers['set-cookie'] can be a string of one cookie, or an array of cookies + // headerCookies should always be an array + const headerCookies = [].concat(headers['set-cookie'] || []) + // Convert 'set-cookie' to Azure Function 3.x cookie object array // https://github.com/Azure/azure-functions-nodejs-worker/blob/v3.x/types/index.d.ts#L150 - if (headerCookies) { + if (headerCookies.length > 0) { for (const headerCookie of headerCookies) { const parsedCookie = parseCookie(headerCookie) const nameValueTuple = headerCookie.split(';')[0].split('=')