我用 Angular 开发了一个网站,并在 proxy.conf.js 文件中有以下代理设置。
const proxyConfig = [
{
context: '/web/api/webclients/**',
target: 'https://10.109.102.109',
changeOrigin: true,
secure: false
},
{
context: '/restful/**',
target: 'https://10.109.110.190',
changeOrigin: true,
secure: false
},
{
context: '/api/**',
target: 'http://10.109.105.107',
changeOrigin: true,
secure: false
}
];
proxy.conf.js 在开发模式下按预期工作。
我将这些放在 package.json 文件中用于启动和构建。
"build": "ng build --aot --prod",
"start": "ng serve --proxy-config proxy.conf.js -o",
当我运行“npm run build”并使用结果文件在 IIS 8 上托管网站后,需要使用代理设置的页面不起作用。
例如我的要求https://localhost/web/api/webclients/身份验证 https://localhost/web/api/webclients/authentication应该去https://10.109.102.109/web/api/webclients/authentication https://10.109.102.109/web/api/webclients/authentication
如果我在 Windows 服务器上托管此网站,如何在 IIS 中设置这些代理设置,或者如果我在非 Windows 服务器上托管该网站,如何设置这些代理设置?