8000 don't use absolute path in redirect for visualizer by timkpaine · Pull Request #2785 · spotify/luigi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

don't use absolute path in redirect for visualizer #2785

New issue 8000

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000 8 changes: 7 additions & 1 deletion luigi/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,13 @@ def get(self, name):

class RootPathHandler(BaseTaskHistoryHandler):
def get(self):
self.redirect("/static/visualiser/index.html")
# 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")

def head(self):
"""HEAD endpoint for health checking the scheduler"""
Expand Down
5 changes: 5 additions & 0 deletions test/server_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
0