Skip to content

Commit

Permalink
fix: follow verified-fetch redirects when subdomains are disabled (#146)
Browse files Browse the repository at this point in the history
Pass `redirect: 'follow'` to `@helia/verified-fetch` when subdomain
support is enabled, otherwise we send a 301 with no `Location` header.
  • Loading branch information
achingbrain authored Apr 11, 2024
1 parent fa925a7 commit b4531c0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/helia-http-gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ export function httpGateway (opts: HeliaHTTPGatewayOptions): RouteOptions[] {
url
})

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

await convertVerifiedFetchResponseToFastifyReply(resp, reply)
}

Expand Down

0 comments on commit b4531c0

Please sign in to comment.