Skip to content

support proxy redirect #138

@mixxen

Description

@mixxen

Your rewrite library seems to be working well. It would be nice if your library supported rewriting proxy redirects. For instance, a proxy is configured like so:

  autoRewrite: true,
  pathRewrite: {
    '^/newpath/' : '/'
  }

If the target server responds with 302, then the client will be redirected to a 404 page because /newpath/ is not appended to the location header. To workaround this, I have modified web-outgoing.js in node_modules/http-proxy to check if autoRewrite is a string. If it is a string, append it to the location. I'm sure there is a better way to do this....

  autoRewrite: '/newpath',
  pathRewrite: {
    '^/newpath/' : '/'
  }
  if (options.hostRewrite) {
    u.host = options.hostRewrite;
  } else if (options.autoRewrite) {
    if(typeof options.autoRewrite === 'string')
      u.host = req.headers['host'] + options.autoRewrite;
    else
      u.host = req.headers['host'];
  }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions