nginx 配置:
header\_filter\_by\_lua\_file cros.lua;
access\_by\_lua '
if ngx.var.request\_method == "OPTIONS" then
return
end
';
cros.lua:
if string.find(ngx.var.http_origin,":8008") then //判断request的origin
ngx.header["Access-Control-Allow-Credentials"] = "true"
ngx.header["Access-Control-Allow-Origin"] = ngx.var.http_origin
ngx.header["Access-Control-Allow-Headers"] = "x-requested-with,content-type"
if ngx.var.request_method == "OPTIONS" then ngx.header["Access-Control-Max-Age"] = ""
ngx.header["Access-Control-Allow-Methods"] = "GET, POST, OPTIONS, DELETE"
ngx.header["Content-Length"] = ""
ngx.header["Content-Type"] = "text/plain, charset=utf-8"
end
end
手机扫一扫
移动阅读更方便
你可能感兴趣的文章