Closed AnuDharmarajan closed 2 years ago
Hi @AnuDharmarajan, and thanks for your contribution! You didn't explain how you came up to the conclusion that the headers were not passed? Do you have access to the server logs? I'll be happy to help when you provide additional information. Thanks!
@jsamr Thank you for your quick replay. I don't have access in the server. The image is in the share point and we are passing the share point token for Authorization.
@AnuDharmarajan Did you manage authentication successfully by other means, with postman or other HTTP utilities, so that you can assert this library is faulty? The provideEmbeddedHeaders
prop is unit-tested, I have doubts the issue is with this library:
I have managed the authentication successfully in the postman and Image view also. It works fine.But in the Renderhtml it is not working.
@AnuDharmarajan Can you log in the console from the first line of your provideEmbeddedHttpHeaders
and test if this log is being called, and if it is, with which arguments? In the snippet you provided, the HTML string is not valid HTML.
The console is called when there is a img tag. I have given a sample HTML in the snippet because I am not able to provide the correct URL in the public platform.
@AnuDharmarajan I am reviewing the code; will let you know.
@AnuDharmarajan It looks like the header
is set after fetching the natural dimensions of the image, which would result in an error. I will provide a patch soon!
@jsamr Thank you.
@AnuDharmarajan Should be fixed in v6.3.0, let me know!
I'm using version 6.3.4 in IOS and this still seems to be an issue. I have an html fragment like follows: and this requires a bearer token to access. I add provideEmbeddedHeaders as follows:
function provideEmbeddedHeaders(uri, tagName, params) {
console.log("provideEmbeddedHeaders: %s", uri);
if (tagName === "img" && uri.includes("?????")) {
const bearerString = `Bearer ${AuthConfig.getAuthToken()}`;
return {
Authorization: bearerString
}
}
}
<RenderHtml
contentWidth={width}
source={source}
enableExperimentalBRCollapsing={true}
provideEmbeddedHeaders={provideEmbeddedHeaders}
debug={true}
renderersProps={renderersProps}
/>
I verified using Postman that the image can be downloaded with the token. Let me know if there are anymore details that can be provided to track down this issue.
Decision Table
<yyy>
is not rendered”Good Faith Declaration
Description
I have added Authorization in img tag it is not working.
React Native Information
RNRH Version
I am using react-native-render-html Version 6.1.0
Tested Platforms
Reproduction Platforms
Minimal, Reproducible Example
function provideEmbeddedHeaders(uri, tagName) {
} return( <RenderHtml contentWidth={Dimensions.get('window').width - wp('10%')} source={{html: '<img src="https://xxxx.xxx.xx/xxxx/xx/xxxx/xxx/xxxx/23553.png"'}} scrollEnabled={false} //enableCSSInlineProcessing={true} baseStyle={{fontSize:normalize(13)}} emSize = {normalize(13)} renderersProps={renderersProps} provideEmbeddedHeaders={provideEmbeddedHeaders} enableCSSInlineProcessing={true} //absoluteFontSizesPixelMap ={'large'} /> )
Additional Notes
No response