From 2fe4622d26733c64483e299fe0842a924bc8d82d Mon Sep 17 00:00:00 2001 From: Sergei Beregov Date: Thu, 23 Nov 2023 11:46:25 +0200 Subject: [PATCH] Add IPv6 loopback address This fixes using broccoli locally with nodejs 18.x. Since node 17.x it favours IPv6 over IPv4: https://github.com/nodejs/node/issues/40537 --- lib/middleware.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/middleware.js b/lib/middleware.js index 1b477aa9..b339a146 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -112,7 +112,7 @@ module.exports = function getMiddleware(watcher, options) { if(request.headers.origin) { // Check if origin resolves to a loopback IP, only add CORS headers if that's the case. dns.lookup(url.parse(request.headers.origin).hostname, function(err, address) { - if(!err && address === '127.0.0.1') { + if(!err && (address === '127.0.0.1' || address === '::1')) { response.setHeader('Access-Control-Allow-Origin', request.headers.origin) writeResponse() }