Nginx设置跨域参数

server {
        #监听端口号
        listen       80;
        #服务的ip地址
        server_name  localhost;
        #允许跨域请求的域,*代表所有
        add_header 'Access-Control-Allow-Origin' *;
        #允许带上cookie请求
        add_header 'Access-Control-Allow-Credentials' 'true';
        #允许请求的方法,比如 GET/POST/PUT/DELETE
        add_header 'Access-Control-Allow-Methods' *;
        #允许请求的header
        add_header 'Access-Control-Allow-Headers' *;
        location / {
            root   html;
            index  index.html index.htm;
        }
}

设置的head中的参数需要一一对应服务端中设置好的参数才可以使用

猜你喜欢

转载自www.cnblogs.com/Mateo-dengmin/p/12068205.html