问题描述
我在 CDN 上有一些图片。
但是出于安全原因,我需要从与页面相同的子域加载一些图像。
module.exports = function relayImage(req,res) {
https.get("https://cdn.mysite.com/foo.jpg",(resp) => {
const dataBlocks = []
resp.on('data',data => dataBlocks.push(data));
resp.on('end',err => {
if(err){
console.error(err)
res.end()
return
}
res.set({
'accept-ranges': "bytes",'cache-control': resp.headers['cache-control'],'content-type': resp.headers['content-type'],'content-length': resp.headers['content-length'],});
dataBlocks.forEach(data => res.send(data))
})
})
}
出于某种原因,这只返回图像顶部的前 2%
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)