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