从本地运行的SAPUI5应用程序访问OData服务

时间:2019-07-20 12:15:45

标签: odata sapui5 sap

我在使用Visual Studio Code在本地运行SAPUI5应用程序时遇到问题。我正在使用由Grunt在localhost:8080运行的静态文件服务器提供webapp文件 问题出在后端OData服务上。第一个问题是我使用NodeJS运行的反向代理解决了CORS错误。

这是反向代理的代码:

var express = require('express');
var app = express();
const https = require('https');
var httpProxy = require('http-proxy');
var apiProxy = httpProxy.createProxyServer();
var backendHost = "YYY-XXX.dispatcher.hana.ondemand.com";
var frontend = 'http://localhost:8080';
var fs = require('fs');

app.all("/sap/opu/*", function (req, res) {
  console.log("HOST:" + req.hostname + " URL: " + req.url);
  apiProxy.web(req, res, {
    changeOrigin: true,
    hostRewrite: false,
    followRedirects: true,   
    autoRewrite: true,
    protocolRewrite: true,    
    preserveHeaderKeyCase: true,
    xfwd:true,
    target: {
      hostname: backendHost,
      port: 443,
      protocol: 'https:',
      host: backendHost,
      agent: https.globalAgent,
      pfx: fs.readFileSync('F:\\Cert.pfx'),
      passphrase: 'XXX',     
    }
  });
});
app.all("*", function (req, res) {
  apiProxy.web(req, res, { target: frontend });
});

var server = require('http').createServer(app);
server.listen(3000);

代码运行正常。当我在浏览器中输入localhost:3000时,我得到了Web应用程序文件,但是我可以看到Webapp向SAP后端(“ YYY-XXX.dispatcher.hana.ondemand.com”)发出的请求产生了以下html回应:

”注意:您的浏览器不支持JavaScript或已关闭。请按按钮继续。 继续”。

另一件事:SAP云平台上是否有针对SAPUI5应用程序的测试环境?我只能看到生产版本的“实时”版本。有暂存环境吗?

我将不胜感激,因为使用Web IDE对我而言不是一种选择。 预先感谢!

0 个答案:

没有答案
相关问题