0

I am having a problem running an SAPUI5 application locally with Visual Studio Code. I am serving the webapp files with a static files server run by Grunt at localhost:8080 The problem is reaching the backend OData services. The first problem which was a CORS error I have solved with using a reverse proxy which is run by NodeJS.

This is the code of the reverse proxy:

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);

The code is running fine. When I enter in the browser localhost:3000 I get the web app files, but I can see that requests made by the webapp towards the the SAP backend ("YYY-XXX.dispatcher.hana.ondemand.com") yields the following html response:

"Note: Your browser does not support JavaScript or it is turned off. Press the button to proceed. Continue"

One more thing: Is there any test environment for the SAPUI5 app on SAP cloud platform? I can only see the "live" version which is the production code. Is there any staging environment?

I would appreciate any help because using Web IDE is not an option for me. Thanks in advance!

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
DTAP
  • 1
  • I recommend using https://caddyserver.com/ for local hosting and reverse proxy, I use it all the time – Jorg Jul 21 '19 at 02:06
  • How do you authenticate against the SAP backend? – Marc Jul 21 '19 at 12:02
  • Concerning your other question: We have 3 different sub accounts in the SCP, one for dev, one for test, one for prod. – Marc Jul 21 '19 at 12:04
  • @Mar: I have added my SAP passport to the request towards the netweaver gateway with lines: pfx: fs.readFileSync('F:\\Cert.pfx'), passphrase: 'XXX', – DTAP Jul 22 '19 at 07:56

0 Answers0