Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot override changeOrigin proxy option #831

Open
JensOlesen47 opened this issue Aug 26, 2022 · 3 comments
Open

Cannot override changeOrigin proxy option #831

JensOlesen47 opened this issue Aug 26, 2022 · 3 comments
Labels

Comments

@JensOlesen47
Copy link

I am attempting to authenticate to a web application using SSO. The apache web server runs on localhost:8080, while the http-server runs on localhost:8443. The problem I'm experiencing is that http-server will rewrite the host header as localhost:8080. As a result, I can authenticate with the SSO server successfully, but I am redirected back to my web server at localhost:8080.

I expected to solve this problem by setting the changeOrigin option to false, but it isn't working as I'd expect it to work.

Environment Versions

  1. OS: Ubuntu 18
  2. Node version: 14.17.2
  3. http-server version: 14.1.1

Steps to reproduce

Run http-server with --proxy-options.changeOrigin false.

Expected result

The changeOrigin flag is true by default, but can be overridden with the above option.

Actual result

The changeOrigin flag is always set to true and the option is ignored.
See lib/http-server.js:

proxy.web(req, res, {
        target: options.proxy,
        changeOrigin: true
}

Other information

I will open a PR if this behaviour is deemed to be a bug.

@github-actions
Copy link

This issue has been inactive for 180 days

@github-actions github-actions bot added the stale label Feb 23, 2023
@tingram-hp
Copy link

I am having the same issue. Is this line the problem?

changeOrigin: true

It seems to be overriding changeOrigin to true after our proxyOptions have been applied.

@JensOlesen47
Copy link
Author

Yep @tingram-hp that's the problem, I forked this repo to fix it, see https://github.com/Stack8/http-server and https://www.npmjs.com/package/s8-http-server

Note, I won't be maintaining that fork, but I don't think this repo is being maintained either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants