feat(index): create a dedicated route for api

to prevent sending cookies on all routes
master
dufraissejeremy 2 years ago
parent b3c88781d7
commit 49ad30f7da
  1. 24
      index.php

@ -0,0 +1,24 @@
<?php
/**
* SPDX-License-Identifier: EUPL-1.2
* Authors: see /README.md
*/
use SeaCMS\Api\JsonResponse;
$end = 'vendor/picocms/plugins/SeacmsApi/index.php';
if (empty($_SERVER['SCRIPT_NAME']) ||
empty($_SERVER['SCRIPT_FILENAME']) ||
substr($_SERVER['SCRIPT_NAME'],-strlen($end)) != $end){
if (!class_exists(JsonResponse::class,false)){
include_once __DIR__.'/src/JsonResponse.php';
}
echo (new JsonResponse(500,['code'=>500,'reason'=>'bad url to run this file']))->send();
} else {
chdir(dirname($_SERVER['SCRIPT_FILENAME'],5));
$GLOBALS['PicoVendorsDirectoryRelativeLevels'] = 4;
include 'index.php';
}
Loading…
Cancel
Save