From cc396dfa3d08ca36c2a27db43b08458b5c6fd1ce Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Fri, 13 Sep 2019 22:51:42 -0400 Subject: [PATCH 1/3] don't use absolute path in redirect for visualizer --- luigi/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luigi/server.py b/luigi/server.py index 41dc28f35b..ef93fe6e0d 100644 --- a/luigi/server.py +++ b/luigi/server.py @@ -271,7 +271,7 @@ def get(self, name): class RootPathHandler(BaseTaskHistoryHandler): def get(self): - self.redirect("/static/visualiser/index.html") + self.redirect("static/visualiser/index.html") class MetricsHandler(tornado.web.RequestHandler): From f7e89636ee3632e898c0d7ecbef2d536dadd24da Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Tue, 1 Oct 2019 14:47:17 -0400 Subject: [PATCH 2/3] add comment --- luigi/server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/luigi/server.py b/luigi/server.py index ef93fe6e0d..4d5aba6407 100644 --- a/luigi/server.py +++ b/luigi/server.py @@ -271,6 +271,12 @@ def get(self, name): class RootPathHandler(BaseTaskHistoryHandler): def get(self): + # we omit the leading slash in case the visualizer is behind a different + # path (as in a reverse proxy setup) + # + # For example, if luigi is behind my.app.com/my/luigi/, we want / to + # redirect relative (so it goes to my.app.com/my/luigi/static/visualizer/index.html) + # instead of absolute (which would be my.app.com/static/visualizer/index.html) self.redirect("static/visualiser/index.html") From ba5ff73ab0c7e2c538c86791183069aaea3f7306 Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Thu, 4 Jun 2020 15:50:16 -0400 Subject: [PATCH 3/3] add test --- test/server_test.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/server_test.py b/test/server_test.py index 23000f1c94..f142523e3a 100644 --- a/test/server_test.py +++ b/test/server_test.py @@ -112,6 +112,11 @@ def test_404(self): def test_api_404(self): self._test_404('/api/foo') + def test_root_redirect(self): + response = self.fetch("/", follow_redirects=False) + self.assertEqual(response.code, 302) + self.assertEqual(response.headers['Location'], 'static/visualiser/index.html') # assert that doesnt beging with leading slash ! + def test_api_preflight_cors_headers(self): response = self.fetch('/api/graph', method='OPTIONS', headers={'Origin': 'foo'}) headers = dict(response.headers)