使用企业网络调用REST API,但始终面临“访问-控制-允许-来源”问题。请在下面的proxy.config.js中找到以启用CORS。我正在使用示例每日天气报告api来生成折线图。请查看下面的API。我也附上了截图,你能帮我解决这个问题吗?
var HttpsProxyAgent = require('https-proxy-agent');
var proxyConfig = [{
context: '/',
target: 'https://samples.openweathermap.org',
secure: false
}];
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;
}
module.exports = setupForCorporateProxy(proxyConfig);

发布于 2018-05-15 18:45:53
激活您的CORS插件以避免访问-控制-允许-原点错误
https://stackoverflow.com/questions/50324655
复制相似问题