mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Add CORS to API endpoints
This commit is contained in:
parent
87e1fa0a28
commit
d0a690c303
2 changed files with 13 additions and 0 deletions
|
@ -3977,6 +3977,7 @@ public_folder "assets"
|
||||||
Kemal.config.powered_by_header = false
|
Kemal.config.powered_by_header = false
|
||||||
add_handler FilteredCompressHandler.new
|
add_handler FilteredCompressHandler.new
|
||||||
add_handler DenyFrame.new
|
add_handler DenyFrame.new
|
||||||
|
add_handler APIHandler.new
|
||||||
add_context_storage_type(User)
|
add_context_storage_type(User)
|
||||||
|
|
||||||
Kemal.config.logger = logger
|
Kemal.config.logger = logger
|
||||||
|
|
|
@ -43,6 +43,18 @@ class FilteredCompressHandler < Kemal::Handler
|
||||||
end
|
end
|
||||||
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
|
class DenyFrame < Kemal::Handler
|
||||||
exclude ["/embed/*"]
|
exclude ["/embed/*"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue