Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Feature request: Custom image headers (AKA `imageHeadersProvider` in Stream Chat Android SDK)

Aperta
#2,990 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
react-native, typescript
Ambito
mobile

Direzione di ricerca

Inizia con lo snippet Avatar.tsx e l’API del componente Chat, quindi segui il modo in cui MessageAvatar, ChannelAvatar e i componenti immagine correlati costruiscono le proprie sorgenti. Definisci dove viene accettato un imageHeadersProvider statico o funzionale e come i suoi header raggiungono le richieste di immagini, inclusa la condizione sull’URL di Stream Chat. Il lavoro è completato quando tutti i percorsi avatar elencati supportano il provider e l’utilizzo esistente rimane invariato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Feature Request

Summary:
This request is for a feature that already exists in Stream Chat Android SDK - imageHeadersProvider (more info on that: https://getstream.io/chat/docs/sdk/android/ui/general-customization/chatui/#adding-extra-headers-to-image-requests)

Background:
We host user avatars on our own CDN that requires a valid Authorization header in order to serve images. Although the Android SDK provides the ability to add extra headers via imageHeadersProvider, the React Native SDK currently does not offer an equivalent feature. This forces us to override channel avatars, message avatars, group avatars, reply avatars and so on...

Using ImageComponent prop on <Chat /> component does not help us because the image source is overriden by your Avatar, MessageAvatar, ... (see more in the snippet below)

Code snippet from Stream Chat Avatar.tsx:

        <ImageComponent
          accessibilityLabel={testID || 'Avatar Image'}
          onError={() => setLoadingImageError(true)}
          source={{

            // Even if our custom ImageComponent has a `headers` key in the image source,
            // it is being overriden here. 

            uri:
              !imageProp ||
              imageProp.includes(randomImageBaseUrl) ||
              imageProp.includes(randomSvgBaseUrl)
                ? imageProp?.includes(streamCDN)
                  ? imageProp
                  : `${randomImageBaseUrl}${
                      name ? `?name=${getInitials(name)}&size=${size}` : ''
                    }`
                : getResizedImageUrl({
                    height: size,
                    resizableCDNHosts,
                    url: imageProp,
                    width: size,
                  }),
          }}
          style={[
            image,
            size
              ? {
                  backgroundColor: '#ececec',
                  borderRadius: size / 2,
                  height: size,
                  width: size,
                }
              : {},
            imageStyle,
          ]}
          testID={testID || 'avatar-image'}
        />

Proposed solution
Introduce an imageHeadersProvider (or similar mechanism) in the React Native SDK that mirrors the functionality available in the Android SDK. This feature should allow developers to supply a function or object that provides custom headers for every image request made by the SDK, ensuring that headers like Authorization are consistently applied across all components. If the SDK supported an imageHeadersProvider, we could easily inject headers (e.g., { Authorization: 'Bearer <token>' }) into every image request.

Acceptance criteria

  • Developers can pass an imageHeadersProvider as a prop on the Chat component.
  • The headers returned by the imageHeadersProvider are automatically applied to all image requests, including those in subcomponents such as MessageAvatar, ChannelAvatar, ... OR consider applying the imageHeadersProvider only if the image source IS NOT a stream chat URL (I would like my JWT token to be sent only to my own servers).
  • The provider accepts either a static header object or a function returning a header object, accommodating dynamic tokens.
  • Existing implementations without imageHeadersProvider remain unaffected.
Lingua principale
TypeScript
Stelle
1.2k
Fork
377
Merge medio
1g 17m
PR unite (30g)
23

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di GetStream/stream-chat-react-native

Tutte le issue di GetStream/stream-chat-react-native

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.