From 6d4cf4fdeaced6d61a43fa6fe211342f46c39708 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Thu, 9 Jan 2025 15:24:56 +0000 Subject: [PATCH 1/3] fix: allow Access-Control-Allow-Origin=* on versions API --- binderhub/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/binderhub/base.py b/binderhub/base.py index b21bfdb5b..f7e15d910 100644 --- a/binderhub/base.py +++ b/binderhub/base.py @@ -216,6 +216,13 @@ class VersionHandler(BaseHandler): # (e.g. mybinder.org federation when blocking cloud datacenters) skip_check_request_ip = True + def set_default_headers(): + if 'Access-Control-Allow-Origin' not in self.settings.get("headers", {}): + # allow CORS requests to this endpoint by default + self.set_header('Access-Control-Allow-Origin', '*') + + super().set_default_headers() + async def get(self): self.set_header("Content-type", "application/json") r = { From ac3b33f6d17da63b7b5ff5e7e02953b5057d3345 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:55:38 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- binderhub/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binderhub/base.py b/binderhub/base.py index f7e15d910..7c5bd11c5 100644 --- a/binderhub/base.py +++ b/binderhub/base.py @@ -217,9 +217,9 @@ class VersionHandler(BaseHandler): skip_check_request_ip = True def set_default_headers(): - if 'Access-Control-Allow-Origin' not in self.settings.get("headers", {}): + if "Access-Control-Allow-Origin" not in self.settings.get("headers", {}): # allow CORS requests to this endpoint by default - self.set_header('Access-Control-Allow-Origin', '*') + self.set_header("Access-Control-Allow-Origin", "*") super().set_default_headers() From f398f88c41b76aa165f9153e592a3144ae3897fd Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Wed, 15 Jan 2025 09:45:35 +0000 Subject: [PATCH 3/3] Update binderhub/base.py Co-authored-by: Min RK --- binderhub/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binderhub/base.py b/binderhub/base.py index 7c5bd11c5..33d7df0ff 100644 --- a/binderhub/base.py +++ b/binderhub/base.py @@ -216,7 +216,7 @@ class VersionHandler(BaseHandler): # (e.g. mybinder.org federation when blocking cloud datacenters) skip_check_request_ip = True - def set_default_headers(): + def set_default_headers(self): if "Access-Control-Allow-Origin" not in self.settings.get("headers", {}): # allow CORS requests to this endpoint by default self.set_header("Access-Control-Allow-Origin", "*")