Invidious is an alternative front-end to YouTube
API: Add APIHandler back
Samantaz Fox7b84bdb29b60
diff --git a/src/invidious.cr b/src/invidious.crindex c8cac80e..e0bd0101 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -217,6 +217,7 @@ public_folder "assets"Kemal.config.powered_by_header = falseadd_handler FilteredCompressHandler.new+add_handler APIHandler.newadd_handler AuthHandler.newadd_handler DenyFrame.newadd_context_storage_type(Array(String))diff --git a/src/invidious/helpers/handlers.cr b/src/invidious/helpers/handlers.crindex cece289b..174f620d 100644--- a/src/invidious/helpers/handlers.cr+++ b/src/invidious/helpers/handlers.cr@@ -134,6 +134,19 @@ class AuthHandler < Kemal::Handlerendend+class APIHandler < Kemal::Handler+ {% for method in %w(GET POST PUT HEAD DELETE PATCH OPTIONS) %}+ only ["/api/v1/*"], {{method}}+ {% end %}+ exclude ["/api/v1/auth/notifications"], "GET"+ exclude ["/api/v1/auth/notifications"], "POST"++ def call(env)+ env.response.headers["Access-Control-Allow-Origin"] = "*" if only_match?(env)+ call_next env+ end+end+class DenyFrame < Kemal::Handlerexclude ["/embed/*"]