动态图像无法加载,显示为文本/html MIME 类型,修复了网络视图?



例如,其中一个图像的链接指向urlhttps://storage.notmywebsite.com/some/path/on/website/image:Static,Small/ImageFileName?params=123456

当通过chrome://inspect,出现的错误是。。。

跨源读取阻止(CORB(阻止了MIME类型为text/html的跨源响应https://login.notmywebsite.com/login.srf?moreparams=123456&wreply=https:%2F%2Fstorage.notmywebsite.com%2Fstorageservice%2Fpassport%2Fauth.aspx%3Fsru%3Dhttps:%252f%252fstorage.notmywebsite.com%252fsome%252fpath%252fon%252fwebsite%252fimage:Static%252cSmall%252fImageFileName&otherparams=123456。看见https://www.chromestatus.com/feature/5629709824032768了解更多详细信息

然而,在Chrome浏览器中加载同一个网站,这些图像就会显示。。。那么出了什么问题呢?有什么办法解决这个问题吗?

我终于发现了问题所在。

对于网络视图,它需要再打开一个设置,才能使用网站的cookie来访问受凭据保护的图像。

因此,如果您想为应用程序修复它,只需使用以下代码即可。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
else
CookieManager.getInstance().setAcceptCookie(true);

最新更新