使用pdf.js当出现跨域问题时,加载将失败,并显示错误消息file origin does not match viewers

原创
小哥 3年前 (2022-12-15) 阅读数 26 #Web前端

使用pdf.js当出现跨域问题时,加载将失败,并显示错误消息file origin does not match viewers。

修改简单粗暴。

直接注释web/viewer.js中的1564到1566这些线,不判断跨域。

if (origin !== viewerOrigin && protocol !== blob:) {
throw new Error(file origin does not match viewer\s);
}
裸露那三条线。

如果地址是流式的,请对其进行编码。

如:viewer.html?file=encodeURIComponent(www.abc.com/test.pdf?token=asdfafasdfa&afs=afsdfds)

有关编码的介绍,请参见:https://blog.csdn.net/qq\_20473985/article/details/84984248


作者:unique_Lee
来源:CSDN
原文:https://blog.csdn.net/qq\_20473985/article/details/84984136
版权声明:本文为博主原创文章,转载请附上博客链接!

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除