Skip to content

Commit 2c0a9b5

Browse files
authored
Merge pull request #14 from tiagobento/do-not-crash-when-getaddrinfo-enotfound
Do not crash with `getaddrinfo ENOTFOUND`
2 parents 1b1c91e + 24a0596 commit 2c0a9b5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

middleware.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ module.exports = ({ origin, insecure_origins = [], authorization = noop } = {})
100100
next()
101101
}
102102
}
103-
function middleware (req, res) {
103+
function middleware (req, res, next) {
104104
let u = url.parse(req.url, true)
105105

106106

@@ -147,7 +147,10 @@ module.exports = ({ origin, insecure_origins = [], authorization = noop } = {})
147147
res.setHeader('x-redirected-url', f.url)
148148
}
149149
f.body.pipe(res)
150-
})
150+
}).catch(e => {
151+
console.error(e);
152+
next();
153+
});
151154
}
152155
const cors = microCors({
153156
allowHeaders,

0 commit comments

Comments
 (0)