git.ntnlv.ca
Repositories
Help
Report an Issue
qdmtl-ts.git
Code
Commits
Branches
Tags
Search
Tree:
5298354
Branches
Tags
prod
qdmtl-ts.git
endpoint.php
CORS: allow any origin for endpoint
davvalent
commited
5298354
at 2024-03-09 18:36:59
endpoint.php
Blame
History
Raw
<?php require 'parse-ini.php'; require 'vendor/autoload.php'; $config = array( 'db_host' => 'localhost', 'db_name' => $infos['db_name'], 'db_user' => $infos['db_user'], 'db_pwd' => $infos['db_pwd'], 'store_name' => $infos['store_name'], 'max_errors' => 25, /* endpoint */ 'endpoint_features' => array( 'select', 'construct', 'ask', 'describe' // 'load', // 'insert', // 'delete' ), 'endpoint_timeout' => 60, // 'endpoint_read_key' => '', /* optional */ // 'endpoint_write_key' => '', /* optional, but without one, everyone can write! */ // 'endpoint_max_limit' => 250, /* optional */ ); /** * Handling CORS * Deprecated since we allow any origin as of 2024-03-09 */ /* $request_headers = getallheaders(); $origin = $request_headers['Origin']; $dev = (str_contains($origin, 'localhost') || str_contains($origin, '127.0.0.1') || str_contains($origin, 'faubourg-demo')) ? true : false; $host_origin = ($dev) ? $request_headers['Origin'] : "https://ntnlv.ca"; header('Access-Control-Allow-Origin: ' . $host_origin); */ // allow any origin header('Access-Control-Allow-Origin: *'); $ep = ARC2::getStoreEndpoint($config); try { if (!$ep->isSetUp()) { $ep->setUp(); } $ep->go(); } catch (Exception $e) { exit('Une erreur est survenue.'); } ?>