Issue #476 resolved

BaseURLFilter doesn't use socket_port

Anonymous created an issue

I'm using sessionAuthenticateFilter and it uses HTTPRedirect. But I use cherrypy on port 8080 and it redirects to urls without :8080.

Reported by Tomas Kolda

Comments (3)

  1. Anonymous

    There was my fault, because baseUrlFilter was turned on. Then it rewrites base without using port and using hardcoded localhost. Maybe this is better:

    Index: filters/baseurlfilter.py
    ===================================================================
    --- filters/baseurlfilter.py    (revision 995)
    +++ filters/baseurlfilter.py    (working copy)
    @@ -13,7 +13,11 @@
                 return
    
             request = cherrypy.request
    -        newBaseUrl = cherrypy.config.get('base_url_filter.base_url', 'http://localhost')
    +        if cherrypy.config.get('server.socketPort', 80) == 80:
    +            defaultUrl = 'http://localhost'
    +        else:
    +            defaultUrl = 'http://localhost:%d' % cherrypy.config.get('server.socketPort', 80)
    +        newBaseUrl = cherrypy.config.get('base_url_filter.base_url', defaultUrl)
             if cherrypy.config.get('base_url_filter.use_x_forwarded_host', True):
                 newBaseUrl = request.headers.get("X-Forwarded-Host", newBaseUrl)
    
  2. Log in to comment