Erant-OldApp/public/index.php

31 lines
575 B
PHP

<?php
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/cors.php';
cors();
$router = new \Bramus\Router\Router();
$router->setBasePath('/');
$router->mount("/api", function() use($router) {
require_once __DIR__ . '/api/index.php';
});
$router->set404('/api(/.*)?', function() {
header('HTTP/1.1 404 Not Found');
header('Content-Type: application/json');
echo json_encode([
"message" => "Route not defined."
]);
});
$router->get("/.*", function() {
header('Content-Type: text/html; charset=UTF-8');
echo "frontend!";
});
$router->run();