Skip to content
New issue

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

Rewrite malformed root url #124

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions jupyter_rsession_proxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ def get_icon_path():

def rewrite_auth(response, request):
'''
As of rstudio-server 1.4ish, it would send the client to /auth-sign-in
rather than what the client sees as the full URL followed by
/auth-sign-in. See rstudio/rstudio#8888. We rewrite the response by
sending the client to the right place.
As of rstudio-server 1.4ish, it would send the client
to a malformed root url when behind a reverse proxy.
We rewrite the response by sending the client to the right place.
'''
correct_root_url = request.host
for header, v in response.headers.get_all():
if header == "Location" and v.startswith("/auth-sign-in"):
if header == "Location" and correct_root_url not in v:
# Visit the correct page
u = urlparse(request.uri)
response.headers[header] = urlunparse(u._replace(path=u.path+v))
u = urlparse(v)
response.headers[header] = urlunparse(u._replace(netloc=correct_root_url))

def setup_rserver():
def _get_env(port):
Expand Down