You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Images with Headers Authentication are not showing. #30017
I am showing headers Auth Images via 'GET method but some images are showing fine and some are not.
in IOS & Android not showing.
The onLoadEnd method also calling fine but still image not showing.
I am Stuck in the last 5 Days.
I think some images are late coming from the URL so maybe the Image tag doing timeOut.
React Native version:
"react": "16.13.1",
"react-native": "0.63.2",
System:
OS: macOS 10.15.6
CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
Memory: 87.70 MB / 8.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.18.3 - /usr/local/bin/node
Yarn: 1.22.4 - ~/.yarn/bin/yarn
npm: 6.14.6 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.0. - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2, 29.0.3
System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Intel x86 Atom_64, android-Q | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6626763
Xcode: 12.0/12A7209 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_221 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.2 => 0.63.2
react-native-macos: Not Found
Steps To Reproduce
Added Image tag
Passed URL Link and Authentication too but in 100 images some of the images are showing and some of the images are not showing.
Expected Results
All Images Need to show fine.
Snack, code example, screenshot, or link to a repository:
Since there are 100 images it is not easy for others to do a repro. Could you try someone debugging and find a similarity between the images that are not loading. Check loading the images using curl or postman to check if the url's are valid. Check the size or file to see if there is any similarity. More information would be helpful to troubleshoot this issue.
Those Images are showing in postman. But not in our app.
Just create min 10 images with authentication, which is less size.
Then you will be able to regenerate the issue. @jeswinsimon .
Thanks for the reply.
I've also been running into this issue. It seems like #25945 might be an older issue for this same thing that was closed, but never actually resolved. It seems like on android only, that image headers either don't send, or don't send in all conditions resulting in the image not being able to render.
Same issue here after upgrading to 0.63.3 from 0.61.4, on Android only.
For reference, the image component appears to be stripping off our Headers (containing Authorization token, and Correlation ID) when the request leaves. Our current implementation for accessing photo resources relies on a call to our Photos service api that provides a 307 response redirect to an external storage url for photos. We have implemented a work-around that pre-fetches the redirect url using Axios interceptors, and then passes this url along to the image component as that url does not require any headers or authorization.
sames here, i trying get image from remote url with auth headers and sometimes is just not working. In onError props i have nativeEvent.error with status code 401, but when i was debugging it turns out that image server do not have any request from mobile app. When i change the url to without auth, the image was downoload.
I am showing headers Auth Images via 'GET method but some images are showing fine and some are not. in IOS & Android not showing. The onLoadEnd method also calling fine but still image not showing. I am Stuck in the last 5 Days. I think some images are late coming from the URL so maybe the Image tag doing timeOut.
React Native version:
"react": "16.13.1",
"react-native": "0.63.2",
System: OS: macOS 10.15.6 CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz Memory: 87.70 MB / 8.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.18.3 - /usr/local/bin/node Yarn: 1.22.4 - ~/.yarn/bin/yarn npm: 6.14.6 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.9.0. - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0 Android SDK: API Levels: 28, 29 Build Tools: 28.0.3, 29.0.2, 29.0.3 System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Intel x86 Atom_64, android-Q | Google Play Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.0 AI-193.6911.18.40.6626763 Xcode: 12.0/12A7209 - /usr/bin/xcodebuild Languages: Java: 1.8.0_221 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.2 => 0.63.2 react-native-macos: Not Found
Steps To Reproduce
Added Image tag
Passed URL Link and Authentication too but in 100 images some of the images are showing and some of the images are not showing.
Expected Results
All Images Need to show fine.
Snack, code example, screenshot, or link to a repository:
For anyone still hitting this on Android, I traced it to Image.android.js (checked on RN 0.86.2, New Architecture).
node_modules/react-native/Libraries/Image/Image.android.js, around lines 201–228:
if(Array.isArray(source_)){const{headers: sourceHeaders,width: sourceWidth,height: sourceHeight}=source_[0];if(sourceHeaders!=null){nativeProps.headers=sourceHeaders;// <- headers only forwarded here}// ...nativeProps.source=source_;}else{const{ uri,width: sourceWidth,height: sourceHeight}=source_;// ...nativeProps.source=[source_];// <- wrapped in an array, but `headers` is never set}
On Android, headers reach the native image view only through the separate headers prop. ReactImageView.setSource() reads just uri, cache, width and height from each source and ignores any headers inside it. That prop is only set in the Array.isArray(source_) branch, so the common form
goes through the else branch: the headers are silently dropped and the request goes out without them (401 in our case). iOS isn't affected because it reads headers from inside each source.
Note this is separate from the redirect case mentioned above. If your server answers with a redirect to another host, the HTTP client on Android (OkHttp) drops Authorization on its own, so passing a pre-resolved or signed URL is still the fix there.
Activity
Biplovkumar commentedon Sep 24, 2020
@admin plz help .
jeswinsimon commentedon Sep 26, 2020
Since there are 100 images it is not easy for others to do a repro. Could you try someone debugging and find a similarity between the images that are not loading. Check loading the images using curl or postman to check if the url's are valid. Check the size or file to see if there is any similarity. More information would be helpful to troubleshoot this issue.
Biplovkumar commentedon Oct 1, 2020
Those Images are showing in postman. But not in our app.
Just create min 10 images with authentication, which is less size.
Then you will be able to regenerate the issue.
@jeswinsimon .
Thanks for the reply.
kylerc commentedon Oct 3, 2020
I've also been running into this issue. It seems like #25945 might be an older issue for this same thing that was closed, but never actually resolved. It seems like on android only, that image headers either don't send, or don't send in all conditions resulting in the image not being able to render.
fairlycasual commentedon Oct 14, 2020
Same issue here after upgrading to 0.63.3 from 0.61.4, on Android only.
For reference, the image component appears to be stripping off our Headers (containing Authorization token, and Correlation ID) when the request leaves. Our current implementation for accessing photo resources relies on a call to our Photos service api that provides a 307 response redirect to an external storage url for photos. We have implemented a work-around that pre-fetches the redirect url using Axios interceptors, and then passes this url along to the image component as that url does not require any headers or authorization.
rastuch commentedon Dec 24, 2020
sames here, i trying get image from remote url with auth headers and sometimes is just not working. In onError props i have nativeEvent.error with status code 401, but when i was debugging it turns out that image server do not have any request from mobile app. When i change the url to without auth, the image was downoload.
bnap00 commentedon Apr 29, 2021
same issue
asaadawey commentedon Aug 5, 2021
any news ?
same here
odyRafaelM commentedon Nov 3, 2021
This is an ongoing issue, headers are not being sent.
marcesengel commentedon Jan 10, 2022
Hello,
I'm currently looking into this issue. It seems to be located in
com.facebook.react.views.imagehelper.MultiSourceHelper.MultiSourceResult, as I can only reproduce it when passing multiple sources. When I temporarily cut down the list to a length of 1, the image will be loaded (and thereby the cache populated). After that it will show at least the cached image, even when switching back to multiple sources, as this is loaded herehttps://github.com/facebook/react-native/blob/6be46b0bb59f2d88bc78e9a72db672bd55914fa7/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.java#L662-L666
The temporary fix is to only pass lists of length 1 on Android.
I will update this as soon as I have fixed the issue or at least found the root cause in case I can't go ahead and fix it.
Edit: I just now realised this issue was about single pictures, I guess I should open a new issue for this.
NilsBaumgartner1994 commentedon Dec 7, 2022
having still the problem
donatoferrulli commentedon May 4, 2023
any news ?
ameyarumbleon commentedon Aug 11, 2023
any updates?
nathanael-e commentedon Sep 4, 2023
I also encounterd this problem.
A workaround, if possible, is to include the token as a query string instead.
github-actions commentedon Mar 2, 2024
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
NilsBaumgartner1994 commentedon Mar 2, 2024
Any updates on this?
react-native-bot commentedon Aug 30, 2024
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
react-native-bot commentedon Sep 6, 2024
This issue was closed because it has been stalled for 7 days with no activity.
MomenMustafa45 commentedon Nov 22, 2026
For anyone still hitting this on Android, I traced it to
Image.android.js(checked on RN 0.86.2, New Architecture).node_modules/react-native/Libraries/Image/Image.android.js, around lines 201–228:On Android, headers reach the native image view only through the separate
headersprop.ReactImageView.setSource()reads justuri,cache,widthandheightfrom each source and ignores anyheadersinside it. That prop is only set in theArray.isArray(source_)branch, so the common formgoes through the
elsebranch: the headers are silently dropped and the request goes out without them (401 in our case). iOS isn't affected because it reads headers from inside each source.Workaround: pass the source as an array:
Possible fix: forward the headers in the
elsebranch too:Note this is separate from the redirect case mentioned above. If your server answers with a redirect to another host, the HTTP client on Android (OkHttp) drops
Authorizationon its own, so passing a pre-resolved or signed URL is still the fix there.