Web海报生成:

71 阅读1分钟

使用插件:dom-to-image;

遇到问题:生成的海报包含微信头像跨域;

跨域链接:https://xxx0/avatar/84b35b527d84198cd49f20da3ab5c81f27738f7c.jpeg

Bff代理链接:http://xxx1/b/api/proxy/file?url=https://xxx0/avatar/84b35b527d84198cd49f20da3ab5c81f27738f7c.jpeg

具体代码:${window.location.origin}/b/api/proxy/file?url=${encodeURIComponent(url)}  // url为跨域微信头像地址;

Bff代理层:window.location.origin}/b/api/proxy/file

代理链接:url=${encodeURIComponent(url)}`// url为跨域微信头像地址;

原理:bff为内部服务器,由bff层请求跨域文件后,转发到内部使用;

dom-to-image参考链接:github.com/tsayen/dom-…