From c1bb75e616dcfef29a92141802854b569c774582 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Tue, 7 Aug 2018 13:18:38 -0500 Subject: [PATCH] Add CORS headers to local URLs --- src/invidious.cr | 12 ++++++++++++ src/invidious/helpers/helpers.cr | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/invidious.cr b/src/invidious.cr index 6e97c70e..e57dd5c6 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -2689,6 +2689,18 @@ options "/videoplayback/*" do |env| env.response.headers["Access-Control-Allow-Headers"] = "Content-Type, range" end +options "/api/manifest/dash/id/videoplayback" do |env| + env.response.headers["Access-Control-Allow-Origin"] = "*" + env.response.headers["Access-Control-Allow-Methods"] = "GET" + env.response.headers["Access-Control-Allow-Headers"] = "Content-Type, range" +end + +options "/api/manifest/dash/id/videoplayback/*" do |env| + env.response.headers["Access-Control-Allow-Origin"] = "*" + env.response.headers["Access-Control-Allow-Methods"] = "GET" + env.response.headers["Access-Control-Allow-Headers"] = "Content-Type, range" +end + get "/videoplayback/*" do |env| path = env.request.path diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 874927e5..fcc191f6 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -17,7 +17,7 @@ class Config end class FilteredCompressHandler < Kemal::Handler - exclude ["/videoplayback/*", "/api/*"] + exclude ["/videoplayback", "/api/*"] def call(env) return call_next env if exclude_match? env