Skip to content

Commit b4531c0

Browse files
authored
fix: follow verified-fetch redirects when subdomains are disabled (#146)
Pass `redirect: 'follow'` to `@helia/verified-fetch` when subdomain support is enabled, otherwise we send a 301 with no `Location` header.
1 parent fa925a7 commit b4531c0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/helia-http-gateway.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ export function httpGateway (opts: HeliaHTTPGatewayOptions): RouteOptions[] {
8787
url
8888
})
8989

90-
const resp = await opts.fetch(url, { signal, redirect: 'manual' })
90+
// if subdomains are disabled, have @helia/verified-fetch follow redirects
91+
// internally, otherwise let the client making the request do it
92+
const resp = await opts.fetch(url, { signal, redirect: USE_SUBDOMAINS ? 'manual' : 'follow' })
93+
9194
await convertVerifiedFetchResponseToFastifyReply(resp, reply)
9295
}
9396

0 commit comments

Comments
 (0)