我已经在我的inside应用程序中配置了一个公司代理,下面是这个常见的解决方案:
var HttpsProxyAgent = require('https-proxy-agent');
var proxyConfig = [
{
context: '/api/*',
target: 'https://somehost/app/',
secure: false,
logLevel: 'debug',
changeOrigin: true,
pathRewrite: {
"^/api": "/api"
}
}
];
function setupForCorporateProxy(proxyConfig) {
var proxyServer = process.env.http_proxy || process.env.HTTP_PROXY;
if (proxyServer) {
var agent = new HttpsProxyAgent(proxyServer);
console.log('Using corporate proxy server: ' + proxyServer);
proxyConfig.forEach(function (entry) {
entry.agent = agent;
});
}
return proxyConfig;
}
例如:遵循下一种格式的api是ok的:http://localhost:4200/api/users或api/resourceX等等
但是,例如,具有下一种格式的API会从后端(400未找到) http://localhost:4200/api/users/abc012-dawd012-423423中产生错误。
我不知道我是不是该给这个“-”什么的。这真的让人困惑,因为其余的API调用都运行得很好。
发布于 2022-02-17 14:59:33
这个问题与上下文的定义有关。这是正确的配置: context:'/api',
https://stackoverflow.com/questions/71156872
复制相似问题