nginx解決跨域問題,在nginx.conf的server中加入以下代碼。
#允許跨域請求的域,*代表所有
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' *;