22 lines
513 B
Plaintext
22 lines
513 B
Plaintext
namespace Http
|
|
|
|
class CorsMiddleware extends HttpRouter
|
|
private origin
|
|
|
|
function new(origin = "*" as string)
|
|
super()
|
|
|
|
m.origin = origin
|
|
|
|
m.All("*", function(context as object) as boolean
|
|
router = context.router
|
|
response = context.response
|
|
response.headers["Access-Control-Allow-Origin"] = router.origin
|
|
return false
|
|
end function)
|
|
end function
|
|
|
|
end class
|
|
|
|
end namespace
|