我们首先从github下载最新的版本:

 curl -JLO https://github.com/mozilla/pdf.js/releases/download/v4.10.38/pdfjs-4.10.38-dist.zip   

直接放到你需要的位置即可。
预览接口为

https://yourdomain.com/path/to/pdfjs/web/viewer.html?file=your_file

在alist中预览的方式是镶嵌到iframe中。这不仅仅是控制台警告和报错,pdf.js会直接拒绝被调用。
我们注释掉/web/view.mjs中的

if (fileOrigin !== viewerOrigin) {
    throw new Error("file origin does not match viewer's");
}

就可以无视风险继续使用啦。