• 错误描述

    nginx 设置了跨域还报cros错误

解决方法

  • 因为请求头中有自定义的头需要添加允许
  • 注意:Token
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
#add_header Access-Control-Allow-Headers Token,Authorization; 

if ($request_method = OPTIONS ) {
    add_header Access-Control-Allow-Origin *; 
    add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
    add_header Access-Control-Allow-Headers Token,Authorization;
    return 200;
}