Skip to content

Commit b4cead0

Browse files
committed
fix: skip x-ipfs-path processing on active gateway
1 parent d80a06a commit b4cead0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

add-on/src/lib/ipfs-request.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ function createRequestModifier (getState, dnslinkResolver, ipfsPathValidator, ru
148148
// Detect X-Ipfs-Path Header and upgrade transport to IPFS:
149149
// 1. Check if DNSLink exists and redirect to it.
150150
// 2. If there is no DNSLink, validate path from the header and redirect
151-
if (state.detectIpfsPathHeader && request.responseHeaders && !request.url.startsWith(state.gwURLString) && !request.url.startsWith(state.apiURLString)) {
151+
const url = request.url
152+
const notActiveGatewayOrApi = !(url.startsWith(state.pubGwURLString) || url.startsWith(state.gwURLString) || url.startsWith(state.apiURLString))
153+
if (state.detectIpfsPathHeader && request.responseHeaders && notActiveGatewayOrApi) {
152154
// console.log('onHeadersReceived.request', request)
153155
for (let header of request.responseHeaders) {
154156
if (header.name.toLowerCase() === 'x-ipfs-path' && isSafeToRedirect(request, runtime)) {

0 commit comments

Comments
 (0)