davvalent

davvalent commited on 2023-04-03 04:29:02
Showing 1 changed files, with 4 additions and 14 deletions.

... ...
@@ -57,22 +57,12 @@
57 57
 
58 58
   /** Handling CORS */
59 59
   $request_headers = getallheaders();
60
-  if (isset($request_headers['Origin'])) {
61
-
62
-    $origin = $request_headers['Origin'];
63
-
64
-    $dev = (str_contains($origin, 'localhost') || str_contains($origin, '127.0.0.1'))
65
-      ? true
66
-      : false;
67
-
68
-      $host_origin = ($dev)
69
-      ? $request_headers['Origin']
60
+  $local_host_referer = (str_contains($request_headers['Referer'], "localhost"))
61
+    ? "http://localhost"
70 62
     : "https://ntnlv.ca";
63
+  header('Access-Control-Allow-Origin: ' . $local_host_referer);
71 64
 
72
-      header('Access-Control-Allow-Origin: ' . $host_origin);
73
-  }
74
-
75
-  /** Access to "Accept header" value */
65
+    /** Access to Accept header value */
76 66
   $accept_header = $request_headers['Accept'];
77 67
 
78 68
   $config = array(
79 69