1、jsonp方式请求获取
前端js请求携带函数名称,后端服务响应内容作为函数参数响应返回
2、后端服务配置跨域响应请求
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Headers", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
3、nginx服务代理设置
location / {
add_header Access-Control-Allow-Origin http://www.domain1.com; #当前端只跨域不带cookie时,可为*
}