接口跨域jsonpwindow.name+iframedomain(同主域)postMessage,WebSocket反向代理(去除跨域)位置^~/api{rewrite/api/(.+)$/$1break;proxy_passhttp://oneApiUrl。com/;indexindex.jsindex.htmlindex.htm;proxy_buffer_size128k;代理缓冲区6464k;proxy_busy_buffers_size256k;proxy_set_header主机$host;proxy_set_headerX-Real-IP$remote_addr;域资源共享CORS详细要点:1.简单请求&复杂请求;2.Cookie图片跨域canvasgetImageData&toDataURL还有一个跨域问题解决方法:corsa标签下载跨域失败解决方法:通过fetch或者xhr下载,转成blob,注意createObjectURL:如果有错误通过axios请求下载文件,具体原因没查。consta=document.createElement('a');consturl="http://******.zip";constfilename="文件名";constxhr=newXMLHttpRequest();xhr.open('get',url);xhr.responseType='blob';xhr.onreadystatechange=function(){if(xhr.readyState===4&&xhr.status===200){constblob=newBlob([xhr.response]);a.href=URL.createObjectURL(blob);a.download=文件名;a.点击();}};xhr.发送();
