Add CORS to API endpoints

This commit is contained in:
Omar Roth
2019-02-02 22:48:47 -06:00
parent 87e1fa0a28
commit d0a690c303
2 changed files with 13 additions and 0 deletions

View File

@@ -43,6 +43,18 @@ class FilteredCompressHandler < Kemal::Handler
end
end
class APIHandler < Kemal::Handler
only ["/api/v1/*"]
def call(env)
return call_next env unless only_match? env
env.response.headers["Access-Control-Allow-Origin"] = "*"
call_next env
end
end
class DenyFrame < Kemal::Handler
exclude ["/embed/*"]