From 699f735b0c13ad1b70444e9e27c32f61df03b776 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 24 Feb 2025 20:07:46 +0100 Subject: [PATCH] fix(peers): chrome regression and update ipfs-geoip to v9.2 (#2333) * fix: update ipfs-geoip to v9.2 https://github.com/ipfs-shipyard/ipfs-geoip/releases/tag/v9.2.0 * fix(peers): avoid HTTP 301 on localhost ?format=raw does not benefit from origin isolation, bu switching to raw IP we use path gateway and return payload immediatelly + avoid issue with chrome upgrading to https:// --- package-lock.json | 8 ++++---- package.json | 2 +- src/bundles/peer-locations.js | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8450b4613..60b1aed62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "intl-messageformat": "^10.3.3", "ip": "^1.1.9", "ipfs-css": "^1.4.0", - "ipfs-geoip": "^9.1.0", + "ipfs-geoip": "^9.2.0", "ipfs-provider": "^2.1.0", "ipld-explorer-components": "^8.1.3", "is-ipfs": "^8.0.1", @@ -40301,9 +40301,9 @@ } }, "node_modules/ipfs-geoip": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/ipfs-geoip/-/ipfs-geoip-9.1.0.tgz", - "integrity": "sha512-1hccF+dtVYdnRzMLmoP6QMtLLG5yHHANnsnxfpY3U5jGX+bN7rrsXJiQ9nWtczN/+CAFRoaOU11A53MsoS0Iww==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/ipfs-geoip/-/ipfs-geoip-9.2.0.tgz", + "integrity": "sha512-f7lS2YppDVxbyDrcIz1G8QmKBOuFdCxyIDpN03/DF13XjnMnyV2YooFswOv+DBlcS4EMyuHTHn6+UvRf6K2gcg==", "license": "MIT", "engines": { "node": ">=16.0.0", diff --git a/package.json b/package.json index 77446f700..85e314bff 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "intl-messageformat": "^10.3.3", "ip": "^1.1.9", "ipfs-css": "^1.4.0", - "ipfs-geoip": "^9.1.0", + "ipfs-geoip": "^9.2.0", "ipfs-provider": "^2.1.0", "ipld-explorer-components": "^8.1.3", "is-ipfs": "^8.0.1", diff --git a/src/bundles/peer-locations.js b/src/bundles/peer-locations.js index e2532c260..6d1252360 100644 --- a/src/bundles/peer-locations.js +++ b/src/bundles/peer-locations.js @@ -234,6 +234,10 @@ class PeerLocationResolver { async findLocations (gatewayUrls, peers) { const res = {} + // Normalize Gateway URLS: + // switch localhost to raw IP to avoid subdomain redirect AND avoid Chrome forcing https:// on such redirect + gatewayUrls = (Array.isArray(gatewayUrls) ? gatewayUrls : [gatewayUrls]).map(url => url.replace(/localhost:(\d+)/, '127.0.0.1:$1')) + for (const p of this.optimizedPeerSet(peers)) { const peerId = p.peer