cancel
Showing results for 
Search instead for 
Did you mean: 

UI5 application using local proxy throws URN error

0 Kudos

Hello,

I followed this tutorial to create local proxy using node.js library. I got rid of the CORS problem, but I have another problem and it is this one:

att.png

I suspect that the problem is caused by defining the data source's uri like this:

"dataSources": {
    "Z_ATTENDANCE_SRV": {
        "uri": "localhost:8081/http://<address>:<port>/sap/opu/odata/SAP/Z_ATTENDANCE_SRV",
        "type": "OData",
        "settings": {
            "odataVersion": "2.0",
            "localUri": "localService/Z_ATTENDANCE_SRV/metadata.xml"
        }
    }
}

I think the problem is cause by "localhost:8081/" prefix in the URI, but I do not know how to get rid of the problem.

proxy.js:

var cors_proxy = require('cors-anywhere');
// Listen on a specific IP Address
// 0.0.0.0 equals localhost
var host = '0.0.0.0';
// Listen on a specific port, adjust if necessary
var port = 8081;
cors_proxy.createServer({
originWhitelist: [], // Allow all origins
requireHeader: ['origin', 'x-requested-with'],
removeHeaders: ['cookie', 'cookie2']
}).listen(port, host, function() {
console.log('Running CORS Anywhere on ' + host + ':' + port);
});

Do you have any suggestions?

former_member560141
Participant
0 Kudos

Can i see the proxy nodejs? If you are running the app on localhost:8081, and then do a call to for example someadress.com/..... it will add localhost:8081/someadress.com/.....

you have to add https://someadress.com/. to not add the localhost.

0 Kudos

Thanks for replay. I have added content of the proxy.js file. So you mean, that instead of 0.0.0.0 I should set ip/address of my service?

View Entire Topic

The solution to this problem is to set port from which the app runs. I run the app in personal WebIDE so my port in 'proxy.js' file is '58513'. Also it is necessary to add 'http://' as a prefix to the data source uri. So my manifest looks like this:

"dataSources": {"Z_ATTENDANCE_SRV": {"uri": "http://localhost:58513/http://<address>:<port>/sap/opu/odata/SAP/Z_ATTENDANCE_SRV","type": "OData","settings": {"odataVersion": "2.0","localUri": "localService/Z_ATTENDANCE_SRV/metadata.xml"}}}

However, I come to another problem which is I get 403 status: Forbidden.

former_member560141
Participant
0 Kudos

Sounds like you need to validate the proxy with SAP. The cookie validation should follow the request to the proxy. Try to not remove the Cookie removeHeaders:['cookie','cookie2']. Make sure the cookie is passed with the proxy req.

0 Kudos

Could you, please, give me some more info about how to implement that? Honestly, I have no idea how to do that.

former_member560141
Participant
0 Kudos

I think you can just remove this line removeHeaders:['cookie','cookie2']

I have never used cors-anywhere to set up a server. So i am not sure. Is that the whole nodejs server?

0 Kudos

I have removed that line, but nothing changed. I also check transaction SU53 if I am not missing some authorizations but it is empty. I know I can get rid of CORS problem using reverse proxy on an appache server, but since I am using personal WebIDE, I have to export the app and install in on local appache server which is too time consuming. Do you know any other approach how to get rid of CORS proble on Personal WebIDE (I want to avoid --disable_security in chrome). Thanks.