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中的参数需要一一对应服务端中设置好的参数才可以使用


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM