Browse Source

Aggiunti header per cross-origin in arav_up_api

cek 8 years ago
parent
commit
e8c857336b
2 changed files with 11 additions and 6 deletions
  1. 2 2
      arav_up.php
  2. 9 4
      arav_up_api/index.php

+ 2 - 2
arav_up.php

@@ -1,6 +1,6 @@
 <?php
 
-ini_set('display_errors',1); 
+ini_set('display_errors',1);
 error_reporting(E_ALL);
 
 // includes
@@ -19,4 +19,4 @@ require 'auth.php';
 // presenta auth
 prompt_auth();
 
-?>
+?>

+ 9 - 4
arav_up_api/index.php

@@ -1,5 +1,10 @@
 <?php
 
+header('Access-Control-Allow-Origin: *');
+header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
+header('Access-Control-Allow-Headers: X-Requested-With');
+header('Access-Control-Max-Age: 86400');
+
 // includes
 $includePath = array();
 $includePath[] = '../arav_up_inclu';
@@ -26,13 +31,13 @@ $authstate = do_local_auth($_SERVER['PHP_AUTH_USER'], hash("sha256",$_SERVER['PH
 // report(1,"dir : ".$authstate["dir"]);
 if ($authstate["esito"] != "AUTH_OK") {
 //     // es: is_inside_dir($object, $authstate["dir"]);
-	prompt_auth();
+    prompt_auth();
 //     report(1,"esito not AUTH_OK, exiting");
-	exit;
+    exit;
 }
 else {
-	// registra in sessione i dati dell'utente //FIXME lo facciamo qui o dentro la funzione do_local_auth?
-	$_SESSION['authstate'] = $authstate;
+    // registra in sessione i dati dell'utente //FIXME lo facciamo qui o dentro la funzione do_local_auth?
+    $_SESSION['authstate'] = $authstate;
 }
 
 // -----------------