根据http://www.meekdeveloper.com/angular-cli-asp-net-core-windows-authentication/中的建议,我使用代理配置从Angular 2调用ASP.NET Web API
ng serve --proxy-config src/proxy.config.js
代理配置如下:
const Agent = require('agentkeepalive');
module.exports = {
'/api': {
target: 'http://localhost/ApplicationApi/',
secure: false,
agent: new Agent({
maxSockets: 100,
keepAlive: true,
maxFreeSockets: 10,
keepAliveMsecs: 100000,
timeout: 6000000,
keepAliveTimeout: 90000
}),
onProxyRes: proxyRes => {
let key = 'www-authenticate';
proxyRes.headers[key] = proxyRes.headers[key] &&
proxyRes.headers[key].split(',');
}
}
};
它适用于开发,但ng-build
没有代理配置参数。
我想将应用程序部署到IIS中,如何在不更改源代码的情况下保留URL前缀(http://localhost/ApplicationApi/)?