tofu-middleware-cors

tofu 的 CORS 中间件

$ opm get d80x86/tofu-middleware-cors

tofu-middleware-cors

tofu 的 CORS(跨域资源共享)中间件

安装

    -- 在项目配置文件 tofu.package.lua 添加
    
    deps = {
    
        -- 
        -- 其它配置 ... 
        --
    
        'd80x86/tofu-middleware.cors',
    }
    


    ## 使用tofu安装
    ./tofu install
    

使用

    -- 项目配置文件 conf/middleware.lua
    
    middleware = {
        -- ... trace 中间件
        -- ..
        -- 添加跨域中间件
        'resty.tofu.middleware.cors'
    
        -- .. 其它中间件.. router, payload, ....
    }
    

配置选项

| 参数名 | 类型 | 默认值 | | ----------------- | ------ | ------------------------------ | | allow_methods | string | GET,HEAD,PUT,POST,DELETE,PATCH | | allow_credentials | bool | 不设置将忽略 | | allow_origin | string | 不设置将自动检测 | | allow_headers | string | 不设置将自动检测 | | expose_heaers | string | 不设置将自动检测 | | max_age | int | 不设置将使用设备默认 |

> 参数详细信息可参考 https://mdn.org.cn/zh-CN/docs/Glossary/CORS

作者

d

许可证

mit

版本