canvas跨域完美解决,微信头像解决跨域

最新的需求中需要把微信头像作为截图的一部分,但是涉及到跨域

解决方案:

location ^~ /wechat_image/ {
  add_header 'Access-Control-Allow-Origin' "$http_origin" always;
  add_header 'Access-Control-Allow-Credentials' 'true' always;
  add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
  add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-   Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
  proxy_pass http://wx.qlogo.cn/;
}

然后将微信的头像 http://wx.qlogo.cn/xxx => http://${自己的域名}/wechat_image/xxx

你可能感兴趣的:(canvas跨域完美解决,微信头像解决跨域)