@@ -31,18 +31,17 @@ def get_icon_path():
3131 os .path .dirname (os .path .abspath (__file__ )), 'icons' , 'rstudio.svg'
3232 )
3333
34- def rewrite_auth (response , request ):
34+ def rewrite_netloc (response , request ):
3535 '''
36- As of rstudio-server 1.4ish, it would send the client to /auth-sign-in
37- rather than what the client sees as the full URL followed by
38- /auth-sign-in. See rstudio/rstudio#8888. We rewrite the response by
39- sending the client to the right place.
36+ In some circumstances, rstudio-server appends a port to the URL while
37+ setting Location in the header. We rewrite the response to use the host
38+ in the request.
4039 '''
4140 for header , v in response .headers .get_all ():
42- if header == "Location" and v . startswith ( "/auth-sign-in" ) :
43- # Visit the correct page
44- u = urlparse ( request .uri )
45- response .headers [header ] = urlunparse (u ._replace (path = u . path + v ))
41+ if header == "Location" :
42+ u = urlparse ( v )
43+ if u . netloc != request .host :
44+ response .headers [header ] = urlunparse (u ._replace (netloc = request . host ))
4645
4746def get_system_user ():
4847 try :
@@ -113,7 +112,7 @@ def _get_timeout(default=15):
113112 'command' : _get_cmd ,
114113 'timeout' : _get_timeout (),
115114 'environment' : _get_env ,
116- 'rewrite_response' : rewrite_auth ,
115+ 'rewrite_response' : rewrite_netloc ,
117116 'launcher_entry' : {
118117 'title' : 'RStudio' ,
119118 'icon_path' : get_icon_path ()
0 commit comments