我想使用
当我尝试使用相同的解决方案(在HTTP下正常工作)时,我会收到一个404错误(但是我可以直接使用浏览器测试此URL访问服务器)。
ng serve
和一个使用Windows身份验证(NTLM)保护的后端服务器。这与以下帖子中的情况非常相似(示例1,示例2),只是服务器通过HTTPS访问。当我尝试使用相同的解决方案(在HTTP下正常工作)时,我会收到一个404错误(但是我可以直接使用浏览器测试此URL访问服务器)。
const Agent = require("agentkeepalive");
module.exports = {
'/api': {
target: "https://my-server.example.com",
secure: false,
changeOrigin: true,
agent: new Agent({
maxSockets: 100,
keepAlive: true,
maxFreeSockets: 10,
keepAliveMsecs: 100000,
timeout: 6000000,
keepAliveTimeout: 90000
}),
onProxyRes: proxyRes => {
const key = "www-authenticate";
proxyRes.headers[key] = proxyRes.headers[key] &&
proxyRes.headers[key].split(",");
}
}
}
任何帮助都将不胜感激,包括一些诊断问题的方法。
更新:使用logLevel = “debug”,我得到以下堆栈跟踪(由于Windows配置,相同的代理配置在HTTPS上运行良好,但我并不理解):
TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
at new ClientRequest (_http_client.js:119:11)
at Object.request (https.js:289:10)
at Array.stream (C:\myproject\node_modules\http-proxy\lib\http-proxy\passes\web-incoming.js:126:74)
at ProxyServer.<anonymous> (C:\myproject\node_modules\http-proxy\lib\http-proxy\index.js:81:21)
at middleware (C:\myproject\node_modules\http-proxy-middleware\lib\index.js:46:13)
at handle (C:\myproject\node_modules\webpack-dev-server\lib\Server.js:322:18)
at app.use (C:\myproject\node_modules\webpack-dev-server\lib\Server.js:330:47)
at Layer.handle_error (C:\myproject\node_modules\express\lib\router\layer.js:71:5)
at trim_prefix (C:\myproject\node_modules\express\lib\router\index.js:315:13)
at C:\myproject\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\myproject\node_modules\express\lib\router\index.js:335:12)
at next (C:\myproject\node_modules\express\lib\router\index.js:275:10)
at Layer.handle [as handle_request] (C:\myproject\node_modules\express\lib\router\layer.js:97:5)
at trim_prefix (C:\myproject\node_modules\express\lib\router\index.js:317:13)
at C:\myproject\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\myproject\node_modules\express\lib\router\index.js:335:12)