Invidious is an alternative front-end to YouTube
Add CORS to API endpoints
Omar Rothd0a690c30314
diff --git a/src/invidious.cr b/src/invidious.crindex abdd8cb9..81318acf 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -3977,6 +3977,7 @@ public_folder "assets"Kemal.config.powered_by_header = falseadd_handler FilteredCompressHandler.newadd_handler DenyFrame.new+add_handler APIHandler.newadd_context_storage_type(User)Kemal.config.logger = loggerdiff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.crindex 91a80203..942757c3 100644--- a/src/invidious/helpers/helpers.cr+++ b/src/invidious/helpers/helpers.cr@@ -43,6 +43,18 @@ class FilteredCompressHandler < Kemal::Handlerendend+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::Handlerexclude ["/embed/*"]