Menu
Yashika Garg
  • About Me
  • Portfolio
  • Blog
  • Work With Me
Yashika Garg

HTML5 Mobile Apps: CORS issue

Posted on December 21, 2016October 30, 2018 by Yashika Garg

Most of Enterprise Mobile Applications need to display large enterprise data generally stored on SAP Systems. For HTML5 Apps, data is accessed by making an AJAX call to the Website and which goes through only if the domain on which the AJAX call is made and the domain to which AJAX call is made, are same.

In such scenario, a simple PROXY can solve the issue. In simple words, we can develop a PHP Layer over our SAP Backend, which it self calls SAP Web-Service, collects the response and as it is echos it to the application.

Below is a sample code for PROXY file in PHP

<?php

define ('HOSTNAME', 'http://LinkToYour.Url');

define ('USERNAME', 'TEST');

define ('PASSWORD', 'TEST');



$path = $_GET['path'];

$request = HOSTNAME.$path;



$ch = curl_init($request);

curl_setopt($ch, CURLOPT_URL, $request);

curl_setopt($ch, CURLOPT_USERPWD, USERNAME . ":" . PASSWORD);

curl_setopt($ch, CURLOPT_TIMEOUT, 30);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //REQUIRED for HTTPS

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$xml = curl_exec($ch);



header("Content-Type: text/xml");

echo $xml;

curl_close($session);

?>

Recent Posts

  • Rebuilt My Website With WordPress
  • Typography Series (Part — 2) — Major challenges
  • Typography Series (Part — 1) — Terminology every frontend developer should know
  • React Unit Testing Series (Part 1)
  • Adobe Flex 4: Mobile Apps: destructionPolicy and popView()

Categories

  • Development (6)
  • Frontend Development (3)
  • Mobile Application Development (2)

Recent Comments

    ©2025 Yashika Garg | Powered by Superb Themes