                     #proxy.on 'proxyRes', (res) ->
                     #    dbg("(mark: #{misc.walltime(tm)}) got response from the target")
 
+                if internal_url?
+                    dbg("changing req.url '#{internal_url}'")
+                    req.url = internal_url
+                else
+                    dbg("leaving req.url unchanged")
                 proxy.web(req, res)
 
     winston.debug("starting proxy server listening on #{opts.host}:#{opts.port}")

                else
                    t = {host:host, port:port}
                    _target_cache[key] = t
                    cb(false, t)
                    if type == 'raw'
                        # Set a ttl time bomb on this cache entry. The idea is to keep the cache not too big,
                        # but also if a new user is granted permission to the project they didn't have, or the project server

        delete _target_cache[key]

    target = (remember_me, url, cb) ->
        {key, type, project_id, port_number, internal_url} = target_parse_req(remember_me, url)

        t = _target_cache[key]
        if t?
            cb(false, t, internal_url)
            return

        dbg = (m) -> winston.debug("target(#{key}): #{m}")
