Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native image from URL that requires headers

I need to display an Image component where the source is a URL that requires http headers passed on to fetch it (for authentication purposes).

How could this be implemented in RN?

Is there a way to add headers to the source?

like image 763
Jellohouse Avatar asked Dec 07 '25 12:12

Jellohouse


1 Answers

This has been added to react-native. See here:

https://reactnative.dev/docs/images.html#network-requests-for-images

Example in link:

<Image
  source={{
    uri: 'https://reactjs.org/logo-og.png',
    method: 'POST',
    headers: {
      Pragma: 'no-cache',
    },
    body: 'Your Body goes here',
  }}
  style={{width: 400, height: 400}}
/>
like image 162
ageoff Avatar answered Dec 09 '25 00:12

ageoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!