React-native: [Android] Images with 301 redirect don't load

Created on 23 Dec 2015  路  21Comments  路  Source: facebook/react-native

Loading images from server where it does a redirect doesn't seem to work on Android. It works fine on iOS.

Demo - https://rnplay.org/apps/UEdIbw

Currently I'm working around this by having a native module which resolves the final URL and sends it back to JavaScript. Its terrible, but at least it gets the job done.

Stale

Most helpful comment

I am using Android - react native 0.48.1 and image with redirect is not loading. So this was only fixed for iOS here correct? - https://github.com/facebook/react-native/commit/192ab663b76dd8e640915c0670830c2de557804f

@satya164 may you please share your solution where the url is resolved then image is loaded?

All 21 comments

Hey satya164, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or not sure whether some behavior is expected or a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using, as well as the platform you're on e.g.- Android, iOS. Thank you for your contributions!

@mkonicek No idea. I had searched, but didn't find anything on this. Also on a quick look, the Native module just seems to pass the URL to Fresco. Thanks for the upvote and the correct link. I had no idea that changing the title changes the link on ProductPains.

Pinged Tyrone.

@mkonicek Thank you 鉂わ笍

In ReactNative apps, Fresco delegates the network request to OkHttp. By default, OkHttp does follow 301 redirects.

We'd need to debug through OkHttp source to find out why this doesn't seem to be happening.

@tyronen Lemme know if I can do anything to help.

@mkonicek @tyronen Has there been any movement on this?

@satya164 I encountered same issue here #5616 , but you mentioned that it works fine on iOS. My APP is built with RN but only for iOS, the pics with 301 will only display sometimes, it's very weird.

I have exactly the opposite problem. Android seemed to be ok, but IOS would only load the image once and subsequent attempts at displaying the image wouldn't work. Looking at the web server logs it doesn't even make a request.

Using RN 0.23

This looks like it was fixed in https://github.com/facebook/react-native/releases/tag/v0.26.0 . I'm going to close the issue but feel free to reopen if I am wrong about that.

@lacker I think what has been fixed in 0.26.0 is just for iOS version, please refer this commit 192ab6.

We can confirm that this issue is still present in version 0.39 and Android, seems to be only fixed for iOS. Please reopen if possible.

Thanks!

Still happening on Android, can confirm on 0.40.
In my case, the bug happens when I try to reach an image created by node.

I see this is happening on iOS as @npomfret reported on April 20.

In Facebook search "Danielles Guide to 504 Plans" which leads you to a card from Spokin Inc. Tapping on that card the first time successfully takes user to the URL http://www.spokin.com/504plans. But hitting back button and tapping on that card going forward goes to a 404.

https://screencast.com/t/EzVFUrP6usQ

Please add a label iOS and also change the title to include iOS

I have encountered same issue with RN v0.4.51 iOS.
I tried to display facebook profile image with the url like this: http://graph.facebook.com//picture?type=large
but not works.
So, I changed the url to redirect target of the url(CDN's url). It works.

I'm sorry, I resolved it and it's not related to this issue.
My issue is caused by App Transport Security. I changed a url to 'https' and it works.

I am using Android - react native 0.48.1 and image with redirect is not loading. So this was only fixed for iOS here correct? - https://github.com/facebook/react-native/commit/192ab663b76dd8e640915c0670830c2de557804f

@satya164 may you please share your solution where the url is resolved then image is loaded?

same here. Images shown randomly

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings