Skip to content

Commit

Permalink
Add IPv6 loopback address
Browse files Browse the repository at this point in the history
This fixes using broccoli locally with nodejs 18.x. Since node 17.x it
favours IPv6 over IPv4: nodejs/node#40537
  • Loading branch information
s22su committed Nov 23, 2023
1 parent f9fcbd2 commit 2fe4622
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 2fe4622

Please sign in to comment.