nignx跨域配置處理
阿新 • • 發佈:2018-11-26
在nginx.conf中配置
server { location / { index index.html index.htm index.php l.php; add_header 'Access-Control-Allow-Origin' '*'; autoindex off; } location /apis { #http://192.168.1.80:19963為訪問另一臺伺服器的介面域名地址 rewrite ^.+apis/?(.*)$ /$1 break; include uwsgi_params; proxy_pass http://192.168.1.80:19963; } }
前端請求:
$.ajax({
type:"post",
dataType: "json",
data:{title:title,content:cont},
url:"/apis/ipfs/hedgeChain/AddBlock",
success:function(res){
}
,error:function (e) {
}
});
瀏覽器顯示請求地址:
實際請求地址:
http://192.168.1.80:19963/ipfs/hedgeChain/AddBlock