-1

I'm new developing sapui5 apps and I'm trying to testing my app in Internet Explorer.

When I test in google Chrome I don't have any problem. Note that I have the next code in the chrome.exe -> --disable-web-security --user-data-dir

When I launch the app in Explorer, the first page does not load.

In Firefox, the first page load, but I can't navigate in the app.

If I remove the --disable-web-security --user-data-dir params from google chrome I obtain the next error:

 Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://my-app.es:port' is therefore not allowed access. The response had HTTP status code 401

I need to upload the app to Gateway.

Can someone helps me?

Thanks!

Pablo Garcia
  • 361
  • 6
  • 23

1 Answers1

0

You seem to be using Cross-origin resources in your Application which is why it does not work. A request is a cross-origin request when the resource belongs to different domain or port than the requesting resource. The flag --disable-web-security --user-data-dir is used to disable cross-origin request blocking in Chrome. Similarly IE has a feature that can be used to enable cross-origin requests.

Internet Explorer > Tools > Internet Options. Select the Security Tab & click on Custom Level button. In the Settings under Miscellaneous > Access data sources across domains, select Enable

This may work for a development environment however it's not ideal for a production scenario.

You can fix this in two ways

  1. Move all of your resources to gateway system and access everything through the gateway. Fetch the UI5 bootstrap from the gateway system with the UI5 resource url("resources/sap-ui-core.js"). Use the same gateway system for OData requests.

  2. If you are fetching external resources from a different server, you will have to add Access control headers on the response headers for that server

    Access-Control-Allow-Origin: *
    
Stephen S
  • 3,936
  • 2
  • 23
  • 33
  • Where I have to place: Access-Control-Allow-Origin: * – Pablo Garcia Mar 06 '17 at 10:20
  • It is not be placed in your code. It has to be enabled on the server of which the resources you are using. Now how it has to be enabled depends on the server which serves these resources. – Stephen S Mar 06 '17 at 10:22
  • Where do you access your UI5 resources from ? The gateway system, different server or an external CDN ? – Stephen S Mar 06 '17 at 10:28
  • The solution was in the index.html file set: src="resources/sap-ui-core.js" – Pablo Garcia Mar 23 '17 at 11:12
  • Well as I said in the first way to fix it, "resources/sap-ui-core.js" will provide the local sapui5 resources on the gateway & eliminate any cross-origin issues. Glad, it worked for you – Stephen S Mar 23 '17 at 11:36
  • 1
    @PabloGarcia I'd suggest to accept this answer to let others know that the issue is resolved. – Boghyon Hoffmann Jan 15 '21 at 19:49