Add CORS middleware
This commit is contained in:
1 parent
386dfc1419
commit
02e44960b7
4 files changed
+28
-1
No files matched your search
@@ -0,0 +1,21 @@
|
||||
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.allow_origin = router.origin
|
||||
return false
|
||||
end function)
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
Reference in new issue
Block a user