cancel
Showing results for 
Search instead for 
Did you mean: 

Getting error to fetch data even after allowing Allow-Control-Allow-Origin: * - Chrome Web Store

Former Member
0 Kudos

Hi ,

I am trying to run one of the example which i saw in scn.During the execution i got following error .even after allowing allow-control-allow-origin in chrome

browser and Please help me how to overcome cross origin in devlopment envirornment at the same time in production envirornment.

XMLHttpRequest cannot load file:///C:/Users/Jagadeesh/Desktop/proxy/http/services.odata.org/Northwind/Northwind.svc/$metadata. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.o.defaultHttpClient.request @ sapui5.hana.ondemand.com/resources/sap/ui/thirdparty/datajs.js:17

my code for calling service

var sURI = "proxy/http/services.odata.org/Northwind/Northwind.svc/";

  var oModel = new sap.ui.model.odata.ODataModel(sURI, true);

  var oTileCont = new sap.m.TileContainer("tc",{});

  //Tile Template

  var oTileTmp = new sap.m.StandardTile({

  icon : "sap-icon://menu",

  title : "{CategoryName}",

  info : "{Description}"

  });

  oTileCont.bindAggregation("tiles","/Categories",oTileTmp);

Accepted Solutions (0)

Answers (4)

Answers (4)

aakash_neelaperumal2
Active Participant
0 Kudos

Hi,

Close all you chrome session and make sure none is running in task manager. And now using command prompt navigate to chrome location as below and enter below highligted command.

This will open a chrome window which will not give you that cross origin error.

C:\Program Files (x86)\Google\Chrome\Application>chrome.exe --disable-web-security


--Aakash

Former Member
0 Kudos

Hi ,

I followed what u mentioned one of  ur previous post.

if  i gave url like

proxy/http/services.odata.org/Northwind/Northwind.svc/ the i got the following error.PFA for the same.

If without using proxy i didnt got any error but warnings and i got only blank screen.

Please help me.

DK007
Active Participant
0 Kudos

Hi,

Execute below command in the Windows run window.

chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security

This would launch a new Chrome browser SESSION. Then in new chrome browser window launch your application. This should work with URL prefixed with proxy.

Thanks,

Dheeram

Former Member
0 Kudos

Hi Dheeram,

I got the following error. and please check my code to.

var sURI = "proxy/http/services.odata.org/Northwind/Northwind.svc/";

            var oModel = new sap.ui.model.odata.ODataModel(sURI, true);

            var oTileCont = new sap.m.TileContainer("tc",{});

           

            var oTileTmp = new sap.m.StandardTile({

                icon : "sap-icon://menu",

                title : "{CategoryName}",

                info : "{Description}"

            });

           

            oTileCont.bindAggregation("tiles","/Categories",oTileTmp);

           

           

            var page = new sap.m.Page();

            page.addContent(oTileCont);

            var app = new sap.m.App();

            app.addPage(page).setInitialPage(page.getId()).placeAt('body');

DK007
Active Participant
0 Kudos

How are you launching/running your application. If its in eclipse, then you can run the application as a Web App Preview. For that you need to configure tomcat and restart the eclipse.

Select index.html and right click on it, Run As and select Web App Preview.

If possible can be you paste complete index.html code.

Thanks,

Dheeram

Former Member
0 Kudos

Hi Dheeram,Thank u for ur instant response,Please find code.I am just running like a html page.

<!DOCTYPE HTML>

<html>

  <head>

  <meta http-equiv="X-UA-Compatible" content="IE=edge" />

  <title>OData Tile Creation</title>

  <script id="sap-ui-bootstrap"

  src="https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js"

  type="text/javascript"

  data-sap-ui-libs="sap.m, sap.me"

  data-sap-ui-theme="sap_bluecrystal">

  </script>

  <script type="text/javascript">

  var sURI = "proxy/http/services.odata.org/Northwind/Northwind.svc/";

  var oModel = new sap.ui.model.odata.ODataModel(sURI, true);

  var oTileCont = new sap.m.TileContainer("tc",{});

  var oTileTmp = new sap.m.StandardTile({

  icon : "sap-icon://menu",

  title : "{CategoryName}",

  info : "{Description}"

  });

  oTileCont.bindAggregation("tiles","/Categories",oTileTmp);

  var page = new sap.m.Page();

  page.addContent(oTileCont);

  var app = new sap.m.App();

  app.addPage(page).setInitialPage(page.getId()).placeAt('body');

  </script>

  </head>

  <body class="sapUiBody" id="body" role="application">

  </body>

</html>

DK007
Active Participant
0 Kudos

Try to change the src to "https://sapui5.hana.ondemand.com/resources/sap-ui-core.js". You are using debug source one. And try to configure tomcat in eclipse and run as a Web App Preview.

Former Member
0 Kudos

I changed src in bootstrap and ran through eclipse then i got following error.Even i tried adding proxy s

0 Kudos

Hello Jagadeesh,

Try using SAP Web IDE to build SAPUI5 applications, its available as trial on cloud

You can create SAPUI5 application  using Northwind service without the proxy or cross-origin problem:

Hope this helps,

Vasu Kesiraju

SAP Technology RIG

Former Member
0 Kudos

HI Vasu,

I got it with webide with destination  but i want to know how to do in a general html page

Former Member
0 Kudos

Why do you use "proxy" before the http url?

Have you already tried this: SOLVED: how to bypass Access-Control-Allow-Origin with javascript only? :: WP Questions ?

Former Member
0 Kudos

Hi Jose,

Thank u for ur reply,

I am new to sapui5,i followed

if u dont mine can u please update above code or some example using NorthWind for odata model

Former Member
0 Kudos

You better read the jquery or ajax calls documentation.

This is not an "SAPUI5 problem".

Former Member
0 Kudos

   can u please help me on this.