zoukankan      html  css  js  c++  java
  • nginx+lua 设置跨域

    nginx 配置:

                            header_filter_by_lua_file cros.lua;
                            access_by_lua '
                            if ngx.var.request_method == "OPTIONS" then
                            return 203
                            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"] = "86400"
          ngx.header["Access-Control-Allow-Methods"] = "GET, POST, OPTIONS, DELETE"
          ngx.header["Content-Length"] = "0"
          ngx.header["Content-Type"] = "text/plain, charset=utf-8"
       end 
    end
  • 相关阅读:
    前端-----盒子模型
    跨域
    DRF的分页
    DRF的权限和频率
    DRF 版本和认证
    DRF的视图和路由
    APIView和View的区别
    Serializers序列化组件
    RESTful
    Vuex以及axios
  • 原文地址:https://www.cnblogs.com/panyangfeng/p/6611894.html
Copyright © 2011-2022 走看看