Refactor code

This commit is contained in:
2025-07-09 08:30:46 +02:00
parent 311cb4e4fa
commit 4aa3a766c6
8 changed files with 193 additions and 104 deletions

View File

@ -1,7 +1,18 @@
<?php
declare(strict_types=1);
$domain = '.lxdapp.local'; // Leading dot is important for subdomain support
use DI\ContainerBuilder;
use Slim\Factory\AppFactory;
use Dotenv\Dotenv;
require __DIR__ . '/../vendor/autoload.php';
// 🔹 Load .env config
$dotenv = Dotenv::createImmutable(__DIR__ . '/../');
$dotenv->load();
$domain = $_ENV['MAIN_COOKIE_DOMAIN'] ?? '.lxdapp.local';
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
@ -14,13 +25,6 @@ session_set_cookie_params([
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
use DI\ContainerBuilder;
use Slim\Factory\AppFactory;
require __DIR__ . '/../vendor/autoload.php';
error_reporting(E_ALL);
ini_set('display_errors', '1');
// Build Container using PHP-DI
$containerBuilder = new ContainerBuilder();
@ -44,11 +48,11 @@ AppFactory::setContainer($container);
// Create App
$app = AppFactory::create();
// 🔹 CORS middleware
$app->add(function ($request, $handler) {
$response = $handler->handle($request);
// $origin = $request->getHeaderLine('Origin') ?: '*';
$origin = $_SERVER['HTTP_ORIGIN'] ?? '*';
return $response
->withHeader('Access-Control-Allow-Origin', $origin)
->withHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization')
@ -56,7 +60,6 @@ $app->add(function ($request, $handler) {
->withHeader('Access-Control-Allow-Credentials', 'true');
});
// Register middleware
(require __DIR__ . '/../src/Bootstrap/middleware.php')($app);

View File

@ -7,3 +7,4 @@
2025-07-08 15:12:49 : http://10.110.90.95:80
2025-07-08 15:23:59 : http://10.110.90.147:80
2025-07-08 15:24:26 : http://10.110.90.147:80
2025-07-09 06:15:42 : http://10.110.90.248:80