跨域问题可以通过配置nginx来解决

跨域问题可以通过配置nginx来解决

location /api/{
    rewrite ^(api/?.*)$ /$1 break;
    proxy_pass "http://localhost:8881";
    proxy_set_header   Host             $host;  
    proxy_set_header   X-Real-IP        $remote_addr;  
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;  
    proxy_set_header   Cookie $http_cookie;  
    add_header Access-Control-Allow-Origin *;  
    add_header Access-Control-Allow-Headers Content-Type;  
    add_header Access-Control-Allow-Methods GET,POST,OPTIONS;  
    add_header Access-Control-Allow-Credentials true;  
}

你可能感兴趣的:(nginx)