Skip to content

Commit

Permalink
fix: compatibility with set headers option (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuintun committed Nov 10, 2020
1 parent 441b449 commit 7c4cac5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}

Expand Down

0 comments on commit 7c4cac5

Please sign in to comment.