Allow file:// request in react-native Webview - android-webview

I am trying to use readiumjs viewer in a react-native webview.
https://github.com/readium/readium-js-viewer
Basically it's an HTML page loading dynamically an epub file. Doesn't seem to work on Android.
I found out that the problem is the request to load the epub is made throught a "file://xxx" uri.
And the webview is blocking it because of his cross-origin request policy.
How can I manage to allow request to file:// ?
I found this for basic Android : Android WebView throws "cross origin requests are only supported for http" exception while trying to load resource from disk
Is there an equivalent with React-native ?

finally I find out that:
https://github.com/lucasferreira/react-native-webview-android
create webview component that allow cross-orignin request to file:///
so it solve my problem.

Related

How to not follow redirects on Flutter Web

I can't figure out how to make a POST request that dosen't automatically follow redirects on Flutter Web. I've tried using Flutter's HTTP library, Dart's HTML library, and a third party plugin Dio, and set the followRedirects flag to false on all of them. All of them have automatically followed redirects anyway, and there are cookies that are only contained in one of the redirects that I am trying to obtain. Using a network inspector I am able to see that all of the redirects are followed and the cookie I am looking for is there, but I can't get the response in Flutter. I have also tried dio's cookiejar plugin, but it dosen't seem to cache any cookies for any uri on Web.
Any help would be appreciated, thanks for reading.

pdf download not working on Android with cordova inappbrowser

In my cordova inappbrowser app, pdfs can be downloaded by calling a RESTful service that streams the content to the user's browser (see html snippet below). This works fine on iOS and using Google Chrome directly on Android but not when doing it through cordova inappbrowser. Clicking on the link doesn't do anything. I've tried many of the suggestions here including using gview but no result.
The tag in html is an href (I tried using window.open as well) that evaluates to something like https://xxx/member/get_pdf/217521359ashr868af6as. Using target='_blank' (tried _system also)
where the value after get_pdf is a guid (value above is not the real guid)
The google viewer workoaround that many people propose works fine with a physical pdfs but my files are streamed back from the service above and gview doesn't recognize it as a pdf and shows error 'preview not available' and its not an option to store them physically. Is there some specific header to set to make gview recognize the streamed response as a pdf? I set content_type, Content-length, tried adding Content-disposition with a filename also. No go.
Any suggestions appreciated.
Thanks,
Patrick

Google de-indexing http://fb://profile/profile-id

http://fb://profile/profile-id violates AMP html policies and has led to Google de-indexing all of my web pages. How can I open my Facebook link on Facebook app when a user click Facebook icon on my site's footer using another way? I am using AMP version for mobile.
Thanks in advance
What error messages do you get after running AMP validation?
Open your page in your browser.
Add "#development=1" to the URL, for example, http://localhost:8000/released.amp.html#development=1.
Open the Chrome DevTools console and check for validation errors.
One problem could be the protocol, use https. After updating the protocol and running validation, do you have any errors?

Facebook and SSL partially encrypted

I got problem when loading Facebook Javascript SDK, it will causing my SSL connection partially encrypted. I try load not using the asychronous one but the result same. Do you have solution for this problem guys?
Thanks
#andriansandi
the code facebook gives to implement the JS SDK uses a protocol relative URL ... The URL of the JS file is //connect.facebook.net/en_US/all.js.
By not specifying http/https the browser will automatically use whichever protocol the page was requested with. Try substituting that with https://connect.facebook.net/en_US/all.js. This will force facebook to load the SDK over https.

UIWebview returns error and adds m. to request URL

I´m trying to load a URL to a webview.
Let´s say the url is: http://www.somepage.com/
But for some reason when I load the url in the webview, it adds a m. (URL looks like this: http://m.somepage.com) , it seems like it´s trying to add a mobile version of the website. There isn´t a mobile version of the website, so it´s trying to load a url that doesn´t exist.
In the shouldStartLoadWithRequest delegate method for the webview, it returns the correct URL. In the didFailWithError method I can an error saying: Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0x5a7c670 {NSErrorFailingURLStringKey=http://m.somepage.com
Any idea how I can fix this? Can I replace the m. with www in some way?
This is most certainly an issue with the webserver. It is redirecting your requests to a domain that does not exist. If you have access to the webserver's configuration you will need to fix this there.
If you don't have access to the webserver, your only chance at avoiding this particular issue is to send a different User-Agent string so that the webserver no longer thinks you are viewing the page from a mobile device. However, there doesn't seem to be an easy way to do this on a site-by-site basis.
Relevant Stack Overflow Question:
Change User Agent in UIWebView (iPhone SDK)
I am using the UIWebView without any issues. Can you check whether the site you are accessing has code that redirects to a mobile version?