Skip to content

Instantly share code, notes, and snippets.

@dunnza
Last active November 7, 2022 07:54
Show Gist options
  • Save dunnza/67c7f1705daba5a1bb5f750d5f5766b1 to your computer and use it in GitHub Desktop.
Save dunnza/67c7f1705daba5a1bb5f750d5f5766b1 to your computer and use it in GitHub Desktop.
How to proxy api requests with NTLM authentication in a create-react-app project
const http = require("http");
const proxy = require("http-proxy-middleware");
module.exports = function(app) {
app.use(
"/api",
proxy({
agent: new http.Agent({ keepAlive: true }),
target: "http://example.com/",
onProxyRes(proxyRes) {
const header = "www-authenticate";
proxyRes.headers[header] =
proxyRes.headers[header] && proxyRes.headers[header].split(",");
}
})
);
};
@dunnza
Copy link
Author

dunnza commented Jun 6, 2019

@TeonWasTaken I'm glad it helped you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment