#允许跨域请求的域,*代表所有
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' *;
add_header 'Access-Control-Allow-Headers' *;
方法一
IIS站点可以直接在站点的HTTP响应标头里设置
方法二:
通过Nginx转发实现
server {
listen 8198;
server_name vue;
#允许跨域请求的域,*代表所有
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' *;
add_header 'Access-Control-Allow-Headers' *;
location / {
root html;
index index.html index.htm;
proxy_pass http://localhost:60889;
}
}