CORS Middleware
CORS middleware enables Cross-Origin Resource Sharing for your application.
local Lynx = require("@lynx/lynx")local cors = require("@lynx/middleware/cors")
local app = Lynx.new()
app:use(cors())Options
You can provide options to the CORS middleware.
app:use(cors({ origin = "*", methods = { "GET", "POST" },}))Full list of options:
origin:string | {string} | (origin: string) -> string- The value of the
Access-Control-Allow-Originheader. A table of origins or a callback function can also be used. Default:*.
- The value of the
methods:{string}?- The value of the
Access-Control-Allow-Methodsheader. Default:{"GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"}.
- The value of the
allowHeaders:{string}?- The value of the
Access-Control-Allow-Headersheader.
- The value of the
exposeHeaders:{string}?- The value of the
Access-Control-Expose-Headersheader.
- The value of the
maxAge:number?- The value of the
Access-Control-Max-Ageheader. Represents the number of seconds the preflight request can be cached.
- The value of the
credentials:boolean?- The value of the
Access-Control-Allow-Credentialsheader.
- The value of the