From 860e57acb0fb32f73cbcc3d1905ed2b08f6ffd03 Mon Sep 17 00:00:00 2001 From: nuintun <1730277+nuintun@users.noreply.github.com> Date: Tue, 10 Nov 2020 15:51:04 +0800 Subject: [PATCH] fix: compatibility with set headers option --- src/middleware.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/middleware.js b/src/middleware.js index 0c5566946..bb06f3478 100644 --- a/src/middleware.js +++ b/src/middleware.js @@ -79,8 +79,19 @@ export default function wrapper(context) { } if (headers) { - for (const name of Object.keys(headers)) { - res.setHeader(name, headers[name]); + const names = Object.keys(headers); + + // Express API + if(res.set) { + for (const name of names) { + res.set(name, headers[name]); + } + } + // Node.js API + else { + for (const name of names) { + res.setHeader(name, headers[name]); + } } }