location / {
    //如果是域名的话是要带http或者https的,这里不用双引号
    add_header Access-Control-Allow-Origin '*';
    // 配置请求方法
    add_header Access-Control-Allow-Methods 'POST,PUT,GET,DELETE';
    // 配置header请求头 如果自定义了header的话,比如'token' 也是需要添加进去的
    add_header Access-Control-Allow-Headers 'version, access-token, user-token, Accept, apiAuth, User-Agent, Keep-Alive, Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With,token'; 
    // 预检请求 OPTIONS做请求
    if ($request_method = 'OPTIONS') {
      return 204;
    }
}
					暂无评论