Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ $ npm start
| `USE_DELEGATED_ROUTING` | Whether to use the delegated routing v1 API | `true` |
| `DELEGATED_ROUTING_V1_HOST` | Hostname to use for delegated routing v1 | `https://delegated-ipfs.dev` |
| `USE_DHT_ROUTING` | Whether to use @libp2p/kad-dht for routing when libp2p is enabled | `true` |
| `USE_SESSIONS` | If true, use a blockstore session per IPFS/IPNS path | `true` |

<!--
TODO: currently broken when used in docker, but they work when running locally (you can cache datastore and blockstore locally to speed things up if you want)
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const FASTIFY_DEBUG = process.env.FASTIFY_DEBUG ?? ''

export const USE_SUBDOMAINS = process.env.USE_SUBDOMAINS !== 'false'

export const USE_SESSIONS = process.env.USE_SESSIONS !== 'false'

export const ECHO_HEADERS = process.env.ECHO_HEADERS === 'true'

/**
Expand Down
8 changes: 6 additions & 2 deletions src/helia-http-gateway.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { raceSignal } from 'race-signal'
import { USE_SUBDOMAINS } from './constants.js'
import { USE_SUBDOMAINS, USE_SESSIONS } from './constants.js'
import { dnsLinkLabelEncoder, isInlinedDnsLink } from './dns-link-labels.js'
import { getFullUrlFromFastifyRequest, getRequestAwareSignal } from './helia-server.js'
import { getIpnsAddressDetails } from './ipns-address-utils.js'
Expand Down Expand Up @@ -89,7 +89,11 @@ export function httpGateway (opts: HeliaHTTPGatewayOptions): RouteOptions[] {

// 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' })
const resp = await opts.fetch(url, {
signal,
redirect: USE_SUBDOMAINS ? 'manual' : 'follow',
session: USE_SESSIONS
})

await convertVerifiedFetchResponseToFastifyReply(url, resp, reply, {
signal
Expand Down