 
             return
 
-        target remember_me, req_url, (err, location) ->
+        target remember_me, req_url, (err, location, internal_url) ->
             dbg("got target: #{misc.walltime(tm)}")
             if err
                 public_raw req_url, query, res, (err, is_public) ->

exports.target_parse_req = target_parse_req = (remember_me, url) ->
    v          = url.split('/')
    project_id = v[1]
    type       = v[2]  # 'port' or 'raw'
    key        = remember_me + project_id + type
    if type == 'port'
        key += v[3]
        port = v[3]
    return {key:key, type:type, project_id:project_id, port_number:port}

exports.jupyter_server_port = jupyter_server_port = (opts) ->
    opts = defaults opts,

                    #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}")
