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中的參數需要一一對應服務端中設置好的參數才可以使用