Skip to content

Commit 7c4cac5

Browse files
authored
fix: compatibility with set headers option (#763)
1 parent 441b449 commit 7c4cac5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/middleware.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,19 @@ export default function wrapper(context) {
7979
}
8080

8181
if (headers) {
82-
for (const name of Object.keys(headers)) {
83-
res.setHeader(name, headers[name]);
82+
const names = Object.keys(headers);
83+
84+
// Express API
85+
if(res.set) {
86+
for (const name of names) {
87+
res.set(name, headers[name]);
88+
}
89+
}
90+
// Node.js API
91+
else {
92+
for (const name of names) {
93+
res.setHeader(name, headers[name]);
94+
}
8495
}
8596
}
8697

0 commit comments

Comments
 (0)